【发布时间】:2017-01-11 00:58:11
【问题描述】:
我已成功显示来自特定类别 ID 的所有产品集合和产品属性值。但是我不知道如何显示产品属性标签。属性标签是硬编码的,但我希望它是自动生成的。
如何显示所有允许在前端看到的产品属性值及其各自的标签?
到目前为止,这就是我所拥有的
<?php
$idValue = 10;
$catagory_model = Mage::getModel('catalog/category')->load($idValue); //where $category_id is the id of the category
$collection = Mage::getResourceModel('catalog/product_collection');
$collection->addCategoryFilter($catagory_model); //category filter
$collection->addAttributeToFilter('status',1); //only enabled product
$collection->addAttributeToSelect('*'); //add product attribute to be fetched
$collection->addStoreFilter();
?>
<table class="full-width-tbl">
<thead>
<tr>
<th>Part Number</th>
<th>Model</th>
</tr>
</thead>
<tbody>
<?php foreach ($collection as $_product): ?>
<tr itemscope itemtype="http://schema.org/IndividualProduct">
<td itemprop="name" style="display:none;"><?php echo $_product->getPart_number() ?></td>
<td itemprop="sku"><?php echo $_product->getModel() ?></td>
</tr>
<?php endforeach ?>
</tbody>
</table>
【问题讨论】:
标签: php content-management-system e-commerce magento-1.9