【发布时间】:2017-04-28 20:54:40
【问题描述】:
我正在尝试在 list.phtml 网格中获取我的可配置产品的所有可用尺寸。
使用下面的代码,我可以成功获取所有尺寸,但它甚至会显示不可用的尺寸。
<?php if($_product->isSaleable()): ?>
<div class="taglie">
<?php $cProduct = Mage::getModel('catalog/product')->load($_product->getId());
//check if product is a configurable type or not
if ($cProduct->getData('type_id') == "configurable") {
//get the configurable data from the product
$config = $cProduct->getTypeInstance(true);
//loop through the attributes
foreach($config->getConfigurableAttributesAsArray($cProduct) as $attributes) { ?>
<?php foreach($attributes["values"] as $values) {
echo "<span>".$values["label"]."</span>";
} ?>
<?php
}
} ?>
</div>
<?php else: ?>
<?php echo $this->__('Out of Stock') ?>
<?php endif; ?>
我想要做的是隐藏不可用的尺寸选项。
【问题讨论】:
标签: php magento magento-1.9