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 0In 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
Rik (OP) already self-answered the question.
Quote:
I solved this topic by a Javascript method, thank you
Note: It's absolutely OK to self-answer your own question. Please just post it as an real answer, but not in a question or comment. Posting as real answer helps to keep the "Unanswered" list more clear (avoids making other people wasting their time).
精彩评论