我需要对magento中的某些产品属性进行自定义查询

时间:2014-10-01 12:28:44

标签: php magento

我需要一个自定义magento query,它可以从数据库中获取以下值:

    product name,
    product link,
    product description,
    product image,
    product price,
    product SKU.

2 个答案:

答案 0 :(得分:2)

试试这些,

$sku = Mage::getModel('catalog/product')->load($_product->getId())->getName();
$sku = Mage::getModel('catalog/product')->load($_product->getId())->getDescription();
$sku = Mage::getModel('catalog/product')->load($_product->getId())->getPrice();
$sku = Mage::getModel('catalog/product')->load($_product->getId())->getSku();
echo Mage::helper('catalog/image')->init($_product, 'small_image')->resize(50,50);

答案 1 :(得分:2)

此SQL将为您提供产品名称。您可以修改此查询,为SKU等添加attribute_identity_type_id

SELECT `value` AS product_name
FROM catalog_product_entity_varchar
WHERE entity_type_id = (SELECT entity_type_id FROM eav_entity_type WHERE entity_type_code = 'catalog_product')
AND attribute_id = (SELECT attribute_id FROM eav_attribute WHERE attribute_code = 'name' AND entity_type_id = (SELECT entity_type_id FROM eav_entity_type WHERE entity_type_code = 'catalog_product'))

如果您有多个attribute_identity_type_id,则使用IN

SQL个关键字