Magento News

 

Magento display configurable attribute values

I need to display, in my homepage, the available colors of a specific configurable product. The availability is based on the stock quantity.

For example, a config. product is associated with these simple producs:

BLACK M –> quantity 5

BLACK S –> quantity 0
BLACK X –> quantity 3
RED M –> quantity 10

RED S –> quantity 25

YELLOW XL –> quantity 0

In this case, I would like to display:

“The available colors:
BLACK , RED “

YELLOW is not included because its quantity is 0

I found out this php method to estimate the quantity, but I can’t show the colors as I would:

$store = Mage::app()->getStore();

$myconfig = Mage::getModel('catalog/product')->setStoreId($store->getId())->load(21765);

$ids = $myconfig->getTypeInstance()->getUsedProductIds();

foreach ($ids as $id):

$simple = Mage::getModel('catalog/product')->load($id); 

$quantity = (int)Mage::getModel('cataloginventory/stock_item')->loadByProduct($simple)->getQty();

endforeach;

The $quantity let a conditional check for the displaying, but I need all the following part…
thanks a lot guys

Magento display configurable attribute values

Possibly Related Posts:


 

Leave a Reply