Sunday 19 April 2015

Magento userful SQL queries

Get sorted attributes for products

SELECT *
FROM  `eav_attribute` ea
LEFT JOIN  `catalog_eav_attribute` cea ON ea.attribute_id = cea.attribute_id
WHERE ea.`entity_type_id` =4
AND cea.`used_for_sort_by` =1
LIMIT 0 , 30; #the value of entity_type_id might be different, but it can be found in the table named `eav_entity_type`
Note: `eav_attribute` is the table of basic product attributes' settings, while `catalog_eav_attribute` is containing additional or advanced settings for product attributes. Most of the product attributes' settings could be found in these two tables.

Set all simple products invisible by SQL Query

update catalog_product_entity_int set value =1 where attribute_id = 102 and  entity_id in (select entity_id from `catalog_product_entity` where `type_id`= 'simple')

Set the position value for all of the products by SQL Query

update `catalog_category_product` set position=2000 where position!=1000;

No comments:

Post a Comment