开发者

Fastest/best way to return attributes of associated products, of a configurable product, that are available to purchase

We're building a custom Ajax product search and are returning attribute options, from associated simple products for a configurable product, that are available to purchase.

In this case, the attribute is 'gender', so to illustrate, I'm trying to show, in the search, whether we have 'Guys, Girls, Kids' in stock, or just 'Guys'.

It's the EXACT same logic as product options on a product page, but it's global.

I have it working with this code:

$attrib开发者_如何学CuteOptions = false;
$jsonConfig = $this->getLayout()->createBlock('Mage_Catalog_Block_Product_View_Type_Configurable')->setProduct($_product)->getJsonConfig();
$jsonConfigDecode = Mage::helper('core')->jsonDecode($jsonConfig);
$genderAttributes = reset($jsonConfigDecode['attributes']);
$attributeOptions = $genderAttributes['options'];

But it's taking up to 1 second per product result so can't be used in our Ajax implementation, which may have dozens of results.

I'm wondering if there's a better/faster way. Perhaps, I'm bypassing flat catalog, which we're using by doing this?

Thanks for your help! Wilson


Better way.

$product->getTypeInstance()->getConfigurableAttributesAsArray()

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜