1

I want to get the available options/items of a layered navigation, but I cannot find out how to achieve this.

Basically, I want to know what filters with items are available, when I set some filters, without having a product collection. For example: I send an request saying size L categories Tshirts and get returned the colors red and blue are availble, but not the color black.

I just cannot find, where the options of my attributes are being filtered.

I hope I could make myself clear.

Thanks

1

Okay, I found a solution, probably not the best as it includes some overhead, but it only needs very few lines of code:

You can get all items by initialising a filter Block:

$items = Mage::app()->getLayout()->createBlock($filterBlockName)->setLayer($layer)->setAttributeModel($attribute)->init();

What I didn't know was how to filter then the returned items. This actually is done by the block itself. So you can just send an reqeust like ?attributecode=value to your controller that creates the block and it returns now only the filtered items.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.