1

Is it possible to change all page layouts through a sql query? I noticed that in the admin section under Catalog > Manage Categories, under the Custom Design tab, there is a dropdown menu for Page Layout. Considering nearly every drop down and select box in the admin section affects a table in the magento database, which table would I have to target in order to change all of my sub categories to "2 columns with left bar".

There are over 100 subcats that need to be changed, and I'd like to do this in one shot rather than manually going through and changing them one at a time.

Thanks!

5

This is stored in the catalog_category_entity_varchar table.

Warning: this is not tested! You should run this on a dev box first to ensure it doesn't break anything.

First, update the page layout for category in the admin in order to get the values you need.

Then you need to get the attribute ID for page layout updates:

select entity_type_id from eav_entity_type WHERE entity_type_code = 'catalog_category';

select attribute_id from eav_attribute WHERE entity_type_id = [value from above query] AND attribute_code = 'page_layout';

Then run the following query to see the values you'll need from your category change:

SELECT * FROM catalog_category_entity_varchar WHERE attribute_id = [value from attribute query];

Finally, run the following query for each subcategory:

INSERT into catalog_category_entity_varchar (entity_type_id, attribute_id, store_id, entity_id, value) VALUES ([entity_type_id], [attribute_id], [store ID], [subcategory_id], '[layout name]';
0

Following Laura Answer:

In my case I had used following bunch of sql queries: Backup table:

RENAME TABLE `catalog_category_entity_varchar` TO `catalog_category_entity_varchar-old`;
CREATE TABLE IF NOT EXISTS `catalog_category_entity_varchar` LIKE `catalog_category_entity_varchar-old`;

Copy data to new table:

INSERT `catalog_category_entity_varchar` SELECT * FROM `catalog_category_entity_varchar-old`;

Now I want to update '1column' for all categories having lavel 2:

UPDATE catalog_category_entity_varchar 
SET 
    value = '1column'
    WHERE
    attribute_id = 61 &&
    entity_id in (SELECT entity_id FROM catalog_category_entity WHERE level = 2)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.