-1

我需要为由设置为“用途”的自定义属性过滤的产品创建一个新的视图模板文件。

到目前为止一切顺利,我有一个按可见性列出产品的模板文件:

<?php
$visibility = array(
  Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH,
  Mage_Catalog_Model_Product_Visibility::VISIBILITY_IN_CATALOG
);

$storeId = Mage::app()->getStore()->getId();
$_productCollection = Mage::getResourceModel('reports/product_collection')
    ->addAttributeToSelect('*')
    ->addOrderedQty()
    ->addAttributeToFilter('visibility', $visibility)
    ->setOrder('ordered_qty', 'desc');
?>

如何使此代码查询“目的”?

4

1 回答 1

1

您可以像添加可见性一样添加它:

$_productCollection = Mage::getResourceModel('reports/product_collection')
    ->addAttributeToSelect('*')
    ->addOrderedQty()
    ->addAttributeToFilter('visibility', $visibility)
    ->addAttributeToFilter('purpose', 'weight-loss')
    ->setOrder('ordered_qty', 'desc');
于 2013-09-26T16:35:07.140 回答