我需要一些编码方面的帮助.我需要获得所有制造商的清单及其相应的magento ID.那可能吗?请帮忙.谢谢.我尝试了一些mod但只得到一个或另一个.如果可能的话,请帮助最后一件事.我提前谢谢你
$attribute = Mage::getModel('eav/config')->getAttribute('catalog_product', 'manufacturer');
foreach ( $attribute->getSource()->getAllOptions(true, true) as $option){
$attributeArray[$option['value']] = $option['label'];
}
foreach($attributeArray as $key=>$val){
echo $val;
}
Run Code Online (Sandbox Code Playgroud)
Dre*_*ter 10
不确定您需要什么格式,但以下示例应说明如何获取所需的值:
$attribute = Mage::getModel('eav/entity_attribute')
->loadByCode('catalog_product', 'manufacturer');
$valuesCollection = Mage::getResourceModel('eav/entity_attribute_option_collection')
->setAttributeFilter($attribute->getData('attribute_id'))
->setStoreFilter(0, false);
$preparedManufacturers = array();
foreach($valuesCollection as $value) {
$preparedManufacturers[$value->getOptionId()] = $value->getValue();
}
if (count($preparedManufacturers)) {
echo "<h2>Manufacturers</h2><ul>";
foreach($preparedManufacturers as $optionId => $value) {
echo "<li>" . $value . " - (" . $optionId . ")</li>";
}
echo "</ul>";
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7332 次 |
| 最近记录: |