在我的商店中,只有可配置的产品是可见的 . 简单的产品是隐藏的 . 每个可配置产品都有相关的简单产品 .
我想按子产品属性过滤可配置产品 .
例如,如果可配置产品子颜色为color = blue,则产品应在产品集合中加载
$attributeCode = 'color'; $attributeValue = 'Blue'; $attribute = Mage::getSingleton('eav/config') ->getAttribute('catalog_product', $attributeCode); if ($attribute->usesSource()) { $options = $attribute->getSource()->getAllOptions(false); } $attributeValueId = 0; foreach ($options as $option) { if ($option['label'] == $attributeValue) { $attributeValueId = $option['value']; } } $productId = YOUR_CONFIGURABLE_PRODUCT_ID; // ID of configurable product $product = Mage::getModel('catalog/product')->load($productId); $childProducts = Mage::getModel('catalog/product_type_configurable') ->getUsedProductCollection($product) ->addAttributeToSelect('*') ->addAttributeToFilter($attributeCode, $attributeValueId);
资料来源:Magento: Filter Configurable Product by Child Product’s Attribute
1 回答
资料来源:Magento: Filter Configurable Product by Child Product’s Attribute