如何使用属性和值数组过滤产品集合

时间:2016-06-07 08:00:04

标签: php magento zend-framework magento-1.9

我正在尝试使用属性和值数组过滤productCollection,但它显示错误,下面是我的代码。请让我知道如何做到......

$requestParams = $this->getRequest()->getParam('requestParams');
$shoppingBy = $requestParams["shoppingBy"];

$attributeCodes = array_keys($shoppingBy);

$productCollection = Mage::getModel("catalog/category")
->load($requestParams['categoryId'])
->getProductCollection();

foreach($attributeCodes as $attributeCode) {
    $attributeValue = $shoppingBy[$attributeCode];
    $filter = array('attribute' => $attributeCode, 'in' => $attributeValue);
    $productCollection = $productCollection->addAttributeToFilter($filter);
}

0 个答案:

没有答案