Adding new export filter for products in Dataflow – profiles in Magento version 1.9

At first, we need to find where the export filters are located. Going through Magento core we can understand that export filters are stored in the form of array inside load () in:


…\app\code\core\Mage\Catalog\Model\Convert\Adapter.php

Look for $attrFilterArray in load(), in that we can see:

$attrFilterArray = array();
$attrFilterArray ['name'] = 'like';
$attrFilterArray ['sku'] = 'startsWith';
$attrFilterArray ['type'] = 'eq';
$attrFilterArray ['attribute_set'] = 'eq';
$attrFilterArray ['visibility'] = 'eq';
$attrFilterArray ['status'] = 'eq';
$attrFilterArray ['price'] = 'fromTo';
$attrFilterArray ['qty'] = 'fromTo';
$attrFilterArray ['store_id'] = 'eq';

Suppose that we need to add a new export filter, let it be country of manufacture, an attribute of product, what we need to do is simple add that attribute just as shown below.


$attrFilterArray = array();
$attrFilterArray ['name'] = 'like';
$attrFilterArray ['country_of_manufacture'] = 'like';
$attrFilterArray ['sku'] = 'startsWith';
$attrFilterArray ['type'] = 'eq';
$attrFilterArray ['attribute_set'] = 'eq';
$attrFilterArray ['visibility'] = 'eq';
$attrFilterArray ['status'] = 'eq';
$attrFilterArray ['price'] = 'fromTo';
$attrFilterArray ['qty'] = 'fromTo';
$attrFilterArray ['store_id'] = 'eq';

The syntax for adding is:


$attrFilterArray ['attributecode'].

Important: we should not edit any core files or templates; this example is demonstrated by editing the core files/templates. We need to override the admin module.

Now, half of the work is done. Next we need to edit the phtml file. For that go to:

..\app\design\adminhtml\default\default\template\system\convert\profile

And open wizard.phtml file. Add the following code inside


<div class="profile_entity_type_product">
<span class="field-row">
<label for="product_filter_country_of_manufacture"><?php echo $this->__("Country of manufacture:") ?></label>
<input id="product_filter_country_of_manufacture" name="gui_data[product][filter][country_of_manufacture]" value="<?php echo $this->getValue('gui_data/product/filter/country_of_manufacture') ?>"/>
</span>

Now check the output and it will work perfectly…

Foradding a category filter, the process is comparatively more complex. There will be a change in logic of load() in Adapter.php. For that, a admin module must be created and Adapter.php must be overrided in such a way that it incorporates or uses the category resource model :
Mage::getResourceModel('catalog/category_collection')Thank you for reading and please share your valuable comments…

This entry was posted in Magento Developer Notes. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *