1
與標題一樣,如何獲取特定商店視圖的屬性選項值而不是當前商店視圖?magento - 按商店視圖獲取屬性選項標籤
我想實現是這樣的:
public function getAttributeOptionValue($attributeCode, $attributeOptionLabel, $storeView)
的attributeOptionLabel是當前屬性選項標籤。
與標題一樣,如何獲取特定商店視圖的屬性選項值而不是當前商店視圖?magento - 按商店視圖獲取屬性選項標籤
我想實現是這樣的:
public function getAttributeOptionValue($attributeCode, $attributeOptionLabel, $storeView)
的attributeOptionLabel是當前屬性選項標籤。
簡單!參考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()
);
看到這個:http://stackoverflow.com/questions/13569039/attribute-options-labels-sorting-define-on-site-view-level/13570016#13570016 –