magento 的一些Sql查询

1,模拟使用getName()获取产品名称的sql

SELECT `value` AS product_name FROM yo_catalog_product_entity_varchar 

WHERE entity_type_id = (SELECT entity_type_id FROM yo_eav_entity_type WHERE entity_type_code = 'catalog_product')

AND attribute_id = (SELECT attribute_id FROM yo_eav_attribute WHERE attribute_code = 'name'

AND entity_type_id = (SELECT entity_type_id FROM yo_eav_entity_type WHERE entity_type_code = 'catalog_product'))

 

2,Mage::getModel('catalog/product')->getCollection()的sql输出

SELECT  `e` . * ,  `price_index`.`price` ,  `price_index`.`tax_class_id` ,  `price_index`.`final_price` , IF( price_index.tier_price IS NOT NULL , LEAST( price_index.min_price, price_index.tier_price ) , price_index.min_price ) AS  `minimal_price` ,  `price_index`.`min_price` ,  `price_index`.`max_price` , `price_index`.`tier_price` 
FROM  `yo_catalog_product_entity` AS  `e` 
INNER JOIN  `yo_catalog_product_index_price` AS  `price_index` ON price_index.entity_id = e.entity_id
AND price_index.website_id =  '1'
AND price_index.customer_group_id =  '4'
LIMIT 0 , 30

 

SELECT `e` . * , `price_index`.`price` , `price_index`.`tax_class_id` , `price_index`.`final_price` , IF( price_index.tier_price IS NOT NULL , LEAST(price_index.min_price, price_index.tier_price ) , price_index.min_price ) AS `minimal_price` , `price_index`.`min_price` , `price_index`.`max_price` ,`price_index`.`tier_price` 
FROM `yo_catalog_product_entity` AS `e` 
INNER JOIN `yo_catalog_product_index_price` AS `price_index` ON price_index.entity_id = e.entity_id
AND price_index.website_id = '1'
AND price_index.customer_group_id = '4'
LIMIT 0 , 30

posted @ 2016-05-13 17:47  lokou  阅读(243)  评论(0编辑  收藏  举报