Magento - 获取每个网站的属性值

时间:2013-08-18 19:21:05

标签: magento magento-1.7

我已经(通过管理面板手动)创建了一个名为att_by_website的属性,该属性的范围是“网站”,我想获得它的几个值。

我该怎么做?我可以通过管理面板设置不同的值,但此时我只能获得默认值。

当我执行$this->getProduct()->getData('att_by_website')时,它只返回默认值($this->getProduct()返回Mage_Catalog_Model_Product的实例)。

谢谢!

2 个答案:

答案 0 :(得分:5)

这可能不是最好的方法,但解决了问题:

$value = Mage::getResourceModel('catalog/product')->getAttributeRawValue($productID, 'att_by_website', $storeId);

答案 1 :(得分:1)

试试这个:

foreach (Mage::app()->getWebsites() as $website) {
    $websiteId = $website->getWebsiteId();
    $storeId = $website->getDefaultGroup()->getDefaultStoreId();
    Mage::app()->setCurrentStore($storeId);

    echo $this->getProduct()->getData('att_by_website');
}