You are here:  » Splitting Categories


Splitting Categories

Submitted by babyuniverse on Sun, 2018-04-01 03:30 in

Hi Mate,

One of my affiliate sites uses categories such as this

Decorative Accents > Gifts For Her > Vases > Ornaments >
Gifts For Her > Vases > Bottles & Jars > Decorative Accents > Gifts For Mum > Home Decor >

How would I be best to split these? Using search and replace or using a modification?
I would like each to be its own category

thanks
Richard

Submitted by support on Tue, 2018-04-03 09:29

Hi Richard,

You can do this with an Explode filter (which splits values on a certain character or string and returns a specific value from the resulting list) however first the ">" character needs to be allowed in as it is removed by normalised by default. To do this, edit the standalone Price Tapestry file 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, for the feed(s) with this style of category, from /admin/ home go to Filters and add a new Explode filter to the Category field. On the configuration page for the filter, enter ">" (without the quotes) as the Explode Character or String, and -1 as the Return Index, which will return the lowest level sub-category from the list...

(don't forget to re-import after adding filters)

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by babyuniverse on Wed, 2018-04-11 10:53

What do I use to bring all the categories back?
Would a find and replace > to , do the trick?

Submitted by support on Wed, 2018-04-11 12:47

Hi Richard,

Do you mean so that for example, after importing a feed with category name:

Decorative Accents > Gifts For Her > Vases > Ornaments

...your site would have individual categories created "Decorative Accents", "Gifts For Her" etc., and the product with that name would then appear in each of the individual categories making up the hierarchy?

If that's the case - it's no problem to modify the script to support multiple categories using comma separation but it is a number of changes so it's easier for me to apply the mod that describe through the forum but if you'd like to give that a go, if you could email me from this installation standalone Price Tapestry files;

includes/admin.php

...and wp-content/plugins/pto/ files;

pto_atoz.php
pto_search.php

...i'll apply the changes for you...

Cheers,
David.
--
PriceTapestry.com

Submitted by babyuniverse on Thu, 2018-04-12 10:18

Hi David,

Yes in this instance it is not a hierarchy, it is actually 4 different categories.
I would for the wordpress post to have 4 different categories.

I tried using find and replace > to , and instead I ended up with 1 category called
Decorative Accents , Gifts For Her , Vases , Ornaments instead of 4 categories.

I will email through the files you have mentioned.

Thanks
Richard