`
kirenenko04
  • 浏览: 146997 次
  • 性别: Icon_minigender_2
  • 来自: 上海
社区版块
存档分类
最新评论

get multiselect attribute values on the product

 
阅读更多
	/**
	 * get multiselect attribute values on the product
	 */
	public function get_mulselect_attr_values($_attribute_code, $productId) {
		$storeId = Mage::app()->getStore()->getStoreId();
		$car_options_csv = Mage::getResourceModel('catalog/product')->getAttributeRawValue($productId, $_attribute_code, $storeId ); // returns: 123,124
		$car_options = explode(',', $car_options_csv);
		$attributeId = Mage::getResourceModel('eav/entity_attribute')->getIdByCode('catalog_product',$_attribute_code);
		$attribute = Mage::getModel('catalog/resource_eav_attribute')->load($attributeId);
		$attributeOptions = $attribute ->getSource()->getAllOptions();
		
		$res = array();
		
		foreach($attributeOptions as $a)
		{
			$l = $a['label'];
			$m = $a['value'];
			if (strlen(trim($l))>0 && in_array($m, $car_options))
			{
				$res[$m] = $l;
			}
		}
		return $res;
	}

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics