码迷,mamicode.com
首页 > 数据库 > 详细

magento 的一些Sql查询

时间:2016-05-13 19:08:43      阅读:435      评论:0      收藏:0      [点我收藏+]

标签:

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

magento 的一些Sql查询

标签:

原文地址:http://www.cnblogs.com/liangsongbai/p/5490228.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!