Magento 1.8 Database – Change All Products Custom Design Template with Query

magento-1.8MySQLquery

Ok I am in the process of updating a theme in Magento 1.8 and have everything set except the products are still showing the old theme. The store has about 1800 products and would take me forever to change the theme for every one manually. Is there a query to change them on all of the products at once?

The setting can be found in the admin panel:
Catalog -> Manage products -> select product -> design -> custom design dropdown
(see image below)

default from old template is chosen

what I would like to change it to, you can see from the image below

new template that I would like to change default to

Any help with this will be greatly appreciated.
Thanks in advance,
jmituzas

Best Answer

First, Magento is manage custom layout using custom_design attribute which is varchar attribute and save attibute value at table catalog_product_entity_varchar

First i have check custom_design attibute id and this id 103 using

Step1: get load product eav attribute

$custom_design = Mage::getResourceModel('catalog/product')->getAttribute('custom_design');

step2: get Attibute id using below code $custom_design->getAttributeId().

step3: get table of this attribute using code $custom_design->getBackend()->getTable();

Alternative process to get custom_design attribute id

Get custom_design attibute id using below code:

SELECT `attribute_id` FROM `eav_attribute` WHERE `attribute_code`='custom_design' and `entity_type_id`=4

Just goto admin>Catalog>Attribute>Maange Attribute>Select attribute custom_design from grid and click on it and in this attribute view page url you can see attribute id

admin/catalog_product_attribute/edit/attribute_id/103/key/e88df75c6ef10d0be06f2aa52b99afef/

Now that mean you update this eav value using below query

update catalog_product_entity_varchar set value ='youdesign template code' 
where  attribute_id =$custom_design->getAttributeId()

enter image description here and you will have some fields

1)entity_id is product id.You can put product id at your condition of update query

2) store_id is import whenever you have multiple store view or website.As custom_design is store_view scope attibute

How to get list OF templates

Just to open any product at admin and goto it Design tab inspect custom design drop down

get list of option values of this attribute

enter image description here

From here you will chose your template like base/default or default/modern or rwd/default

Note:You will update value with NULL that means it always design from your Store current design template and package .

Most of cases product design it take from Current store design template,so it showing NULL

Final Query Look like:

update catalog_product_entity_varchar set value ='your design design template code' 
where  attribute_id =$custom_design_code
Related Topic