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;
	}

 

你可能感兴趣的:(attribute)