You are here:  » Categories


Categories

Submitted by augirl on Tue, 2016-01-19 02:24 in

Is there anyway to import top category and sub category as many feeds have top category the sub category on one line like this Dog Supplies > Collars, When imported like this it just does it as Dogsuppliescollars. Can I created extra field like sku for topcategory and use category for subcategory. Would this be any good can you help please.

Take Care

Submitted by support on Tue, 2016-01-19 09:15

Hello augirl,

The best way to handle categories already represented in a feed is to use an Explode filter to return either top, or lowest category in the hierarchy, whichever you prefer to use, however, since the ">" character is removed by the normalisation this must first be permitted. To do this, edit includes/admin.php and look for the following code at line 199:

      $importRecord["category"] = tapestry_normalise($importRecord["category"]);

...and REPLACE with:

      $importRecord["category"] = tapestry_normalise($importRecord["category"],">");

With that in place, you can then attach an Explode filter to the Category field for this feed, and for the Explode Character or String enter ">" (without the quotes), and for the Return Index, use 0 for the top most category, or -1 for the lowest level sub-category.

Whilst it would certainly be possible to add a custom field to hold sub-category, I am in fact working on an Extension that would let you import an already defined category hierarchy within a feed into Category Hierarchy Mapping - i'll let you know as soon as this is ready to try..!

Cheers,
David.
--
PriceTapestry.com

Submitted by augirl on Mon, 2016-02-01 17:22

Hi

I am not sure about the return index. Where do I put 0 and where do I put -1
Can you assist please.

Thank you

Submitted by support on Mon, 2016-02-01 17:38

Hi,

The value required would should be put in the "Return Index" box on the configuration page for an instance of an Explode filter. After adding an Explode filter to the Category field, the Configuration page should display;

Explode character or string:
[ ]
Return index:
[ ]

So in the case of wishing to use the lowest level sub-category as your feed category values, this would be configured as:

Explode character or string:
[> ]
Return index:
[-1 ]

Conversely, if you wished to use the top level category name then it would be:

Explode character or string:
[> ]
Return index:
[0 ]

When the Explode filter splits an input value (the feed value) on the Explode Character or String entered it creates a list of the separated out values, which is zero-based, so 0 returns the first value, 1 the second and so forth. Negative values however count from the end backwards, and is -1 based.

Hope this helps, let me know if you're still not sure of course, or if the filter is configured but not having the expected results...

Cheers,
David.
--
PriceTapestry.com

Submitted by augirl on Tue, 2016-02-02 00:40

Hi

Think brain gone on strike but still don't understand where to put it.
Does it go on end below.
$importRecord["category"] = tapestry_normalise($importRecord["category"], >);

Take Care
Thank you for all your support

Submitted by support on Tue, 2016-02-02 09:46

Hi,

Ah sorry - that's the only code required however I notice from the line in your post that the quotes are missing around the > character, replacement should be:

      $importRecord["category"] = tapestry_normalise($importRecord["category"],">");

Once you have uploaded the modified file, the rest of the process is in the /admin/ area of your Price Tapestry installation. Login, and then click Filters alongside the feed that contains the category values such as "Dog Supplies > Collars". Select the "Explode" filter, and the Category field from the drop down boxes, and then click Add. You'll then be on the Configuration page for the filter instance where you'll find the boxes for Explode Character or String and Return Index as described above...

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by mannvenn on Sun, 2017-04-09 02:01

Did something change in the new version 16/10A?

With 15/09A the explode worked fine. But it's not working in 16/10A

Mentioned > in explode character and return index but not working, still seem to combine catagory/sub cat

We have different seperators for many merchants.

I tried the steps in this thread and hard coded

$importRecord["category"] = tapestry_normalise($importRecord["category"], ">");

but it only works for either > or ~ for example. Not both.

Submitted by support on Mon, 2017-04-10 07:49

Hi,

There shouldn't be any change in the Explode filter functionality from 15/09A to 16/10A - bear in mind you can specify multiple characters to allow in the second parameter in the call to tapestry_normalise(), for example to permit > and ~ use:

  $importRecord["category"] = tapestry_normalise($importRecord["category"], ">~");

If still not working as expected, if you could let me know a couple of example feed category values, and how you have modified the above line I'll check it out further with you...

Cheers,
David.
--
PriceTapestry.com

Submitted by mannvenn on Tue, 2017-04-11 10:34

Hi David

OK adding >~ seems to work.

Now when I return -1 I get only the child category, or 0 I get the parent category as well

I am trying to create category hierarchy mapping and I m trying to create a menu
For eg,
Men
Women
and sub categories.

Within the file I have

WOMEN>>CLOTHING>>PANTS

its so hard to manually do each and every one.

Submitted by support on Tue, 2017-04-11 12:38

Hi!

I've had a number of requests recently regarding auto-generation of the Category Hierarchy from a hierarchy already outlined within a feed category field (e.g. this thread) so this is something I am currently working on.

It's not totally straight forward for example due to the possibility of feeds from different merchants / networks having a different hierarchy, so the mod needs to have the option to auto-generate the hierarchy either from any feed, or under certain conditions such as a single feed, or where the feed can be identified as having the hierarchy required. Other feeds could then be mapped into the auto-generated hierarchy in the normal way.

Keep an eye on the forum and I'll post an update as soon as I've come up with something to try...

Cheers,
David.
--
PriceTapestry.com

Submitted by mannvenn on Tue, 2017-04-11 13:50

Great thanks David.