You are here:  » Import only product of mapped categories


Import only product of mapped categories

Submitted by magnaromagna on Wed, 2020-12-30 19:08 in

Hi,
is there an option or an hack to import only product from feed of mapped categories? Something like
if feed category is mapped do import, else skip

Thank you in advance!

Submitted by support on Thu, 2020-12-31 10:15

Hi,

You can add this easily, firstly for Category Hierarchy Mapping which I believe you are using from your other question, edit includes/admin.php and look for the following comment at line 447:

    /* check product record for minimum required fields */

...and REPLACE with:

    if (!$importRecord["categoryid"]) return;
    /* check product record for minimum required fields */

Alternatively, if you are using basic feed category mapping, then REPLACE with:

    if (!in_array($importRecord["category"],$admin_importCategoryHierarchyMappings)) return;
    /* check product record for minimum required fields */

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by magnaromagna on Fri, 2021-01-01 17:06

Hi!
Yes,I'm using Category Hierarchy Mapping.

There is a strange behavior: if I add this hack, if I go on PT --> Category Hierarchy Mapping and click on Reverse Mapping, I cannot see/filter anymore Unmapped Only. I see only already mapped categories. (and cannot import products, i click on Slow Import but nothing change, value is the same of trial import)
If I revert the original includes/admin.php I can see again also Unmapped categories. And can import (all products)

Thank you again

Submitted by support on Sat, 2021-01-02 09:14

Hi,

Ah sorry, make sure you have _not_ add this line to includes/admin.php.

    if (!in_array($importRecord["category"],$admin_importCategoryHierarchyMappings)) return;

...that would cause all unmapped categories to disappear, and is incorrect it should have been:

    if (!in_array($importRecord["category"],$admin_importCategoryMappings)) return;

...which is how to apply mapped categories only for basic Category Mapping.

So the only line that should have been added is:

    if (!$importRecord["categoryid"]) return;

However, this does mean of course that having applied that mod, unmapped categories will no longer be in the database so it would need to be temporarily disabled (comment out the line and re-import) when working on Category Hierarchy Mapping in order to be able to see the unmapped categories...

Cheers,
David.
--
PriceTapestry.com

Submitted by magnaromagna on Sat, 2021-01-02 09:20

Hi,
yes, I'm using it by comment/uncomment line, seems working.

Thanks.