如何在属性上显示产品数量?
代码/核心/法师/目录/砌块/类别/ View.php
public function getAllManu()
{
$product = Mage::getModel('catalog/product');
$attributes = Mage::getResourceModel('eav/entity_attribute_collection')
->setEntityTypeFilter($product->getResource()->getTypeId())
->addFieldToFilter('attribute_code', 'product_properties');
$attribute = $attributes->getFirstItem()->setEntity($product->getResource());
$product_properties = $attribute->getSource()->getAllOptions(false);
return $product_properties;
}
view.phtml
<select class="form-control" onchange="if (this.value) window.location.href=this.value">
<option>Select</option>
<?php foreach ($this->getAllManu() as $product_properties): ?>
<option value="<?php Mage::getURL() ?>catalogsearch/advanced/result/?product_properties[]=<?php echo $product_properties['value'] ?>"><?php echo $product_properties['label'] ?></option>
<?php endforeach; ?>
</select>
答案 0 :(得分:0)
Gokhan,使用count()函数计算集合项集合
<select class="form-control" onchange="if (this.value) window.location.href=this.value">
<option>Select</option>
<?php foreach ($this->getAllManu() as $product_properties): ?>
$productcollection = Mage::getModel('catalog/product')->getCollection()->addAttributeToFilter('product_properties', $product_properties['value'])
->addAttributeToFilter('status',array('eq' => Mage_Catalog_Model_Product_Status::STATUS_ENABLED));;
$productcollection = $productcollection->addCategoryFilter(Mage::getModel('catalog/category')->load($currcategory),true);
$productcollection->count();
<?php endforeach; ?>
</select>
$rel_products ->count();