Thursday, August 19, 2010

get attribute value for configurable product

//this function will get the configurable products set
public function getprodco_without_visib(){
$categories=$this->get_categories();
$storeId = Mage::app()->getStore()->getId();
$this->_collection = Mage::getModel('catalog/resource_eav_mysql4_product_collection')
->setStoreId($storeId)
->addCategoriesFilter($categories)
->addAttributeToSelect('*')
->setOrder('created_at', 'desc')
->addAttributeToSelect('*');
return $this->_collection;
}


function getatt_label_basedoncode($attrb_code,$product){
$attributeValue = Mage::getModel('catalog/product')
->load($product->getId())
->getAttributeText($attrb_code);

return $attributeValue;
}

//GET all product id with their attribute selected value in an array

function getproduct_attrbset_array(){
$prodattarr=array();
$prods = $this->getprodco_without_visib();
foreach ($prods as $product) {
//$product = Mage::getModel('catalog/product')->load(14);
$prodattarr[] = array(
'attset' => $this->getatt_label_basedoncode('your_attrib_code',$product),
'prod_id' =>$product->getId(),
);
}
return $prodattarr;
}

No comments:

Post a Comment