问题
Like the title, how can I get the attribute option value of a specific store view instead of the current store view ?
What I am trying to implement is something like this :
public function getAttributeOptionValue($attributeCode, $attributeOptionLabel, $storeView)
The attributeOptionLabel is the current attribute option label.
回答1:
Simple! Ref Mage_Eav_Model_Entity_Attribute::getStoreLabel() [link]:
<?php
include 'app/Mage.php';
Mage::app('default');
//Generic access
$eavConfig = Mage::getSingleton('eav/config');
/* @var $eavConfig Mage_Eav_Model_Config */
$eavAttribute = $eavConfig->getAttribute(
Mage_Catalog_Model_Product::ENTITY, // 'catalog_product'; see db.eav_entity_type
'description' // attribute code
);
/* @var $eavAttribute Mage_Eav_Model_Entity_Attribute */
Zend_Debug::dump(
$eavAttribute->getStoreLabel('admin')
);
//For a given EAV entity-based model, the resource requires only the attribute
$product = Mage::getModel('catalog/product')->load(2);
/* @var $product Mage_Catalog_Model_Product */
$productAttribute = $product->getResource()->getAttribute('description');
/* @var $productAttribute Mage_Eav_Model_Entity_Attribute */
Zend_Debug::dump(
$productAttribute->getStoreLabel('admin')
);
//It's also possible to get all labels:
Zend_Debug::dump(
$productAttribute->getStoreLabels()
);
来源:https://stackoverflow.com/questions/13683378/magento-get-attribute-option-label-by-store-view