1

we have several layered categories that contain configurable products

Now for that category we want to "auto-apply" a filter

So say: they open category X, then the page is alread "pre-filtered" for variable SIZE=12

Can this be done through XML update? or other?

many thanks, Sean

Example something like add to collection filter (but then in XML)

enter image description here

  • Looking @ stackoverflow.com/questions/13755707/… --- would it be an option to write a simple extension that adds a "action method" having two params: key and value => and the helper method influences the collection based on an attribute filter? – snh_nl Feb 3 '15 at 21:07
1

We are investigating / debugging this. Must be possible!!

While reading this as a reference: Setting variables, we came up with the following:

1: set data=> Custom Layout Update in category (none working, so that's whye so many calls: WIP)

<reference name="content">
  <action method="setAttributeFilterName"><value>shirt_size</value></action>
  <action method="setAttributeFilterValue"><value>1</value></action>
</reference>

<reference name="product_list">
  <action method="setAttributeFilterName"><value>shirt_size</value></action>
  <action method="setAttributeFilterValue"><value>2</value></action>
</reference>

<reference name="left">
  <action method="setAttributeFilterName"><value>shirt_size</value></action>
  <action method="setAttributeFilterValue"><value>3</value></action>
</reference>

<action method="setAttributeFilterName"><value>shirt_size</value></action>
<action method="setAttributeFilterValue"><value>4</value></action>

<catalog_category_view>
  <reference name="product_list">
    <action method="setAttributeFilterName"><value>shirt_size</value></action>
    <action method="setAttributeFilterValue"><value>5</value></action>
  </reference>
</catalog_category_view>

<catalog_category_layered>
  <reference name="product_list">
    <action method="setAttributeFilterName"><value>shirt_size</value></action>
    <action method="setAttributeFilterValue"><value>6</value></action>
  </reference>
</catalog_category_layered>

2: collection get data=> Influence category collection set-up and picking up the value again as a filter

$f = $this->getData('attribute_filter_name');
$v = $this->getData('attribute_filter_value');
Mage::log('1: '.$f.'-'.$v,Zend_Log::DEBUG,'debug.log',true);

Mage::log('1: '.$this->getAttributeFilterName().' - '.$this->getAttributeFilterValue(),Zend_Log::DEBUG,'debug.log',true);

if (false) {
    $collection->addAttributeToFilter($this->getAttributeFilterName(), $this->getAttributeFilterValue());
}

3: Conclustion=> Not working yet, any help appreciated

1

Reading this article: https://stackoverflow.com/questions/26050724/magento-setting-variables-via-the-custom-layout-updates-xml-on-a-per-category

We had the idea of just adding this to custom layout update

<catalog_category_view>
 <reference name="product_list">
   <action method="setShirtSize"><value>10</value></action>
 </reference>
</catalog_category_view>

but then we read this and here it states that the SetData command is accessed after the layout generation...

https://stackoverflow.com/questions/9844685/passing-data-from-layout-to-block-controller-using-setdata

(and we need it ofcourse before to apply the layered navigation filter

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.