Advanced Export Profile in Magento: Filtering Products for External Channels
As an experienced Magento developer, I often encounter situations where clients need to export specific products from their store inventory to external channels like Nextag or Pricegrabber. The challenge is how to create a profile that accurately filters only the desired products.
Understanding the Export Profile Structure
Before we dive into filtering, let’s quickly review what an export profile looks like in Magento:
<action type="catalog/convert_adapter_product" method="load">
<var name="store">5</var>
<var name="filter/type">simple</var>
<var name="filter/price/from">90</var>
<var name="filter/price/to">6000</var>
<var name="filter/status">1</var>
</action>
<action type="catalog/convert_parser_product" method="unparse">
<var name="store">5</var>
<var name="url_field">1</var>
</action>
<!-- More actions... -->
Creating a Filter Attribute for Export
To filter products for export, you can create a new boolean attribute called “Export”. This attribute will serve as a flag to include or exclude specific products from the exported file.
- Navigate to Catalog > Attributes > Manage Attributes.
- Click on ‘Add New Attribute’.
- Set the Attribute Code to “export”.
- Choose ‘Yes/No’ as the Input Type.
- Save the attribute and apply it to your product catalog.
Modifying the Export Profile to Filter Products
Now, let’s modify your existing export profile to filter only products with the “Export” flag set to Yes:
- Open the export profile in a text editor or use Magento’s built-in XML editor.
- Locate the
actionresponsible for loading the product list. In your example, it looks like this:
<action type="catalog/convert_adapter_product" method="load">
<var name="store">5</var>
<var name="filter/type">simple</var>
<var name="filter/price/from">90</var>
<var name="filter/price/to">6000</var>
<var name="filter/status">1</var>
</action>
- Add a new filter for the “Export” attribute:
<action type="catalog/convert_adapter_product" method="load">
<!-- Original filters -->
<var name="store">5</var>
<var name="filter/type">simple</var>
<var name="filter/price/from">90</var>
<var name="filter/price/to">6000</var>
<var name="filter/status">1</var>
<!-- New filter for Export attribute -->
<var name="filter/export/eq">1</var> <!-- Assuming Yes = 1 in your attribute settings -->
</action>
Conclusion
With this modification, your export profile will now only include products that have the “Export” flag set to Yes. This approach provides fine-grained control over which products are exported to external channels.
Remember, when working with Magento XML profiles, always backup your data before making changes and test the exports thoroughly to ensure they meet your requirements.
For more advanced Magento development techniques, feel free to explore our other tutorials at Laravel Company.