1

I want to filter the exported products by category, but what I have isn't working:

<action type="catalog/convert_adapter_product" method="load">
    <var name="store"><![CDATA[0]]></var>
    <var name="filter/type"><![CDATA[simple]]></var>
    <var name="filter/category"><![CDATA[my-category]]></var>
</action>

<action type="catalog/convert_parser_product" method="unparse">
    <var name="store"><![CDATA[0]]></var>
    <var name="url_field"><![CDATA[0]]></var>
</action>

<action type="dataflow/convert_mapper_column" method="map">
    <var name="map">
        <map name="sku"><![CDATA[MPN/UPC]]></map>
        <map name="brand"><![CDATA[Manufacturer]]></map>
        <map name="name"><![CDATA[Product Name]]></map>
        <map name="product_link"><![CDATA[product_link]]></map>
        <map name="condition"><![CDATA[Product Condition]]></map>
        <map name="price"><![CDATA[Selling Price]]></map>
        <map name="shipping_costs"><![CDATA[Shipping costs]]></map>
        <map name="weight_box1"><![CDATA[Weight]]></map>
    </var>
    <var name="_only_specified">true</var>
</action>

<action type="dataflow/convert_parser_csv" method="unparse">
    <var name="delimiter"><![CDATA[,]]></var>
    <var name="enclose"><![CDATA["]]></var>
    <var name="fieldnames">true</var>
</action>

<action type="dataflow/convert_adapter_io" method="save">
    <var name="type">file</var>
    <var name="path">var/export</var>
    <var name="filename"><![CDATA[catonly.csv]]></var>
</action>

Looks like <var name="filter/category"><![CDATA[my-category]]></var> doesn't work.

1

From this Magento KB article, it seems that we are limited to a set of predefined filters (name, sku, type, attribute_set, price/from, price/to, qty/from, qty/to, visibility, status)

To use another filter, you must create a small extension, example here: https://stackoverflow.com/a/7342066/729440

For categories, you'll want to load your category using Mage::getModel('catalog/category')->load($your_cat_id_here); and then use addCategoryFilter

1

Although an accepted answer, I would like to place another alternative: Using profile definition to own adapter.

First step is to create your own advanced import/export profile. You can simply copy the profile xml from the existing export profile located in system->import/export->dataflow profiles.

Once copied, adjust the adapter to your own adapter class

Example xml, with adapter changed:

<action type="viyet_importexport/convert_adapter_product" method="load">
    <var name="store"><![CDATA[0]]></var>
</action>
<action type="catalog/convert_parser_product" method="unparse">
    <var name="store"><![CDATA[0]]></var>
    <var name="url_field"><![CDATA[0]]></var>
</action>
<action type="dataflow/convert_mapper_column" method="map">
</action>
<action type="dataflow/convert_parser_csv" method="unparse">
    <var name="delimiter"><![CDATA[,]]></var>
    <var name="enclose"><![CDATA["]]></var>
    <var name="fieldnames">true</var>
</action>
<action type="dataflow/convert_adapter_io" method="save">
    <var name="type">file</var>
    <var name="path">var/export</var>
    <var name="filename"><![CDATA[export_all_products.csv]]></var>
</action>

The important part is the first bit:

<action type="viyet_importexport/convert_adapter_product" method="load">
        <var name="store"><![CDATA[0]]></var>
    </action>

Then define your own adapter class, extending the core adapter that is usually used.

class Viyet_ImportExport_Model_Convert_Adapter_Product
    extends Mage_Catalog_Model_Convert_Adapter_Product
{
    /**
     * Retrieve not loaded collection
     *
     * @param string $entityType
     * @return Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection
     */
    protected function _getCollectionForLoad($entityType)
    {
        $collection = Mage::getResourceModel($entityType.'_collection')
            ->setStoreId($this->getStoreId())
            ->addStoreFilter($this->getStoreId());
        $categoryObject = mage::getModel('catalog/category')->load(Mage::getStoreConfig('importexport/attributes/category_id'));
        if($categoryObject->getId()) {
            $collection->addCategoryFilter($categoryObject);
        }
        return $collection;
    }
}

This then give you the ability to override the base class method that builds the collection, which you can then use to add a category filter.

0

I would suggest using the "Enhanced Product Grid" extension, see below:

http://www.magentocommerce.com/magento-connect/enhanced-admin-product-grid.html

Free to use this one.

Then, you have the ability to add a category filter to your manage products page in your admin area.

You can then extract just the category you want.

I think this is what you are looking for?

P.S. I would thoroughly recommend using Magmi for any imports of products:

http://sourceforge.net/apps/mediawiki/magmi/index.php?title=Magmi_Wiki

Hope this helps?

2
  • While it could work, I really would like to know why the filter doesn't work on the advanced dataflow. – localhost Oct 7 '13 at 18:48
  • Yeah, understand what you mean. I haven't used the advanced dataflow in a while though so not sure I can help you any further there. We fell out with it some time ago due to limitations and slow uploads, and have used Magmi ever since. – MagentoMac Oct 7 '13 at 18:50

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.