属性将组中的所有属性分组

php
阅读 51 收藏 0 点赞 0 评论 0

mg1-attr-group
<?php
$attributeGroupId = '';
$attributeSetCollection = Mage::getResourceModel('eav/entity_attribute_group_collection')->load();
foreach ($attributeSetCollection as $id=>$attributeGroup) {
    if($attributeGroup->getAttributeGroupName() == 'Technical Data' || $attributeGroup->getAttributeGroupName() == $this->__('Technical Data')) {
        $attributeGroupId = $attributeGroup->getAttributeGroupId();
        break;
    }
}
if(!empty($attributeGroupId)):
    $attributesCollection = Mage::getResourceModel('catalog/product_attribute_collection');
    $attributesCollection->setAttributeGroupFilter($attributeGroupId);
?>
<div class="twocols2">
    <div class="col">
        <dl class="technical-data">
            <?php
                $counter = 0; foreach ($attributesCollection as $attribute) :
                $inputType = $_product->getResource()->getAttribute($attribute->getAttributeCode())->getFrontend()->getInputType();
                switch ($inputType) {
                    case 'multiselect':
                    case 'select':
                    case 'dropdown':
                        $attributevalue = $_product->getAttributeText($attribute->getAttributeCode());
                        if (is_array($value)) {
                            $value = implode(', ', $value);
                        }
                        break;
                    default:
                        $attributevalue = Mage::getResourceModel('catalog/product')->getAttributeRawValue($_product->getId(), $attribute->getAttributeCode(), Mage::app()->getStore()->getStoreId());
                    break;
                }
                if(!empty($attributevalue)): ++$counter;
            ?>
                <dt><?php echo $attribute->getFrontendLabel();  ?> : </dt>
                <dd><?php echo $attributevalue; ?><br></dd>
                <?php if($counter%24 == 0 && $counter != 0 && count($attributesCollection) != $counter)
                    echo '</dl></div><div class="col"><dl class="technical-data">';
                ?>
            <?php endif; endforeach; ?>
        </dl>
    </div>
</div>
<?php endif; ?>
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号