Today I had to create a static block quickly via SQL queries because for some reason the grid in Content > Blocks didn’t work. First I created the static block itself.
1 |
INSERT INTO cms_block (title, identifier, content) VALUES ('Lorem Ipsum', 'loprem_ipsum', '<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry.</p>'); |
Values for fields creation_time, update_time and is_active are not required because MySQL will add default values.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
mysql> DESCRIBE cms_block; +---------------+--------------+------+-----+-------------------+-----------------------------+ | Field | Type | Null | Key | Default | Extra | +---------------+--------------+------+-----+-------------------+-----------------------------+ | block_id | smallint(6) | NO | PRI | NULL | auto_increment | | title | varchar(255) | NO | MUL | NULL | | | identifier | varchar(255) | NO | | NULL | | | content | mediumtext | YES | | NULL | | | creation_time | timestamp | NO | | CURRENT_TIMESTAMP | | | update_time | timestamp | NO | | CURRENT_TIMESTAMP | on update CURRENT_TIMESTAMP | | is_active | smallint(6) | NO | | 1 | | +---------------+--------------+------+-----+-------------------+-----------------------------+ 7 rows in set (0.00 sec) |
After that I created the relation between static block and the actual store.
1 |
INSERT INTO cms_block_store (block_id, store_id) VALUES (32, 0); |
In order to get the correct block_id you simply have to get block_id from the table cms_block.
1 |
SELECT * FROM cms_block WHERE identifier = 'lorem_ipsum'; |
In my case the block_id of my new static block was 32. That’s it.