You are here:  » extra category field


extra category field

Submitted by michael on Thu, 2012-09-13 15:38 in

Hi David
i was wondering would it be possible to add an extra field into the filter or/and to the url structure, the problem i have is that there are 16,000 category's in our products not including duplicates or variations the reason for this is we are using the city information as our category structure, but for a large amount of our products we have country information i wondered would it be possible to add the county information to the url so like if i had a category for london i could have the url as category/england/london or if theres any other way, i have the country and city names already passing in the url to make requests off if theres a way i could call the results like that?

Best Regards,

Michael.

Submitted by support on Fri, 2012-09-14 06:37

Hi Michael,

I assume you're talking about the plugin - look for the function pto_insertRewriteRules() in pto.php where you'll find the rewrite rules for, amongst others, the /product/ URLs - look for where $pto_config_productBaseHREF is used at line 285. The rules are in standard .htaccess format. What you can do is then co-ordinate that rule with the way the /product/ links are generated which is within the pto_common_productHREF() function in pto_product.php. The input variable $product is a PHP object representing a product record from the database, so to incorporate a custom field country use the variable $product->country

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by michael on Fri, 2012-09-21 16:08

Hi David thanks for the reply,

sorry took me so long to get back to you,
i haven't had a go at altering this yet but im guessing something like this is what is needed:

if($product->country !=""){
   $c = trim($product->country,"/");
}else{
   $c = trim("uncategorized","/");
}
$c .= trim($pto_config_categoryBaseHREF,"/");

but i cant see how it would work this way, but before i can do that i have a problem with the category mapping not working correctly since the last import of xml's dont understand why its been thrown out all the mapping appears to be there in the mapping table but when i try visit one of the categorys it just takes me to the pto base with no results

Best Regards,

Michael

Submitted by support on Mon, 2012-09-24 08:32

Hi Michael,

Are the empty category pages from hard coded links in your theme? The first thing I would check is the actual category list as seen by the database - try browseing to the category index at /category/ (assuming default settings) and check that selecting a category from there does then show results as expected.

That should work fine; and if so would indicate that your latest feed update doesn't contain the same category names as your entries in the Alternatives box on the configuration pages for your mappings. What I would have thought is more likely is that perhaps a transient error in the feed generation means that all category fields are empty rather than having changed - I would think this is more likely than an across the board renaming of categories. I would check in the feed manually - if it is small enough to be opened in a text editor or your browser (browse to /feeds/feedname) and then use the search function to try and locate the categories that you're expecting.

To incorporate the category, with "uncategorized" if not present into the product URL you're on the right lines - where the existing code to generate the product URL is as follows (line 48 in pto_product)...

return get_bloginfo('url').$pto_config_productBaseHREF.pto_common_hyphenate($product->normalised_name).".html";

..you might use:

if($product->country !=""){
   $c = $product->country;
}else{
   $c = "uncategorized";
}
return get_bloginfo('url').$pto_config_productBaseHREF."/".$c."/".pto_common_hyphenate($product->normalised_name).".html";

...and the corresponding changes to the rewrite rules as described above e.g.

$newrules['('.trim($pto_config_productBaseHREF,'/').')/(.*)/(.*).html$'] = 'index.php?pagename='.$pto_config_permalink.'&pto_module=product&pto_product=$matches[3]';

Cheers,
David.
--
PriceTapestry.com

Submitted by michael on Fri, 2012-10-05 18:08

hi David
Sorry to bother you with this but at some point we seem to have broke the category, brand, merchant mapping, basically the problem being category mapping no longer works, when you try to visit one of the pages it just takes you to the root price-tapestry page on wordpress, the filter still works but, if we try visit a category page it doesnt show any results same if we try to visit a brand or merchant page, so im a bit puzzled

we dint try to do the modifications above yet. so im not sure at what point we seem to have broke the href pages.

thanks,

Michael

Submitted by support on Sun, 2012-10-07 10:44

Hello Michael,

That sounds like the rules for /merchant, /category etc. - which can be configured via the Virtual Base HREF settings in wp-admin > Settings > PriceTapestry.org - are not currently set. You can invoke a flush rules (which will cause WordPress to re-build its internal rewrite table) by

1) Making a temporary change to one of the Virtual Base HREF settings, e.g. by changing Category Base HREF from "/category" to "/categorytemp".

2) Browse to your root Price Tapestry page e.g. /shopping

3) Return to the configuration page, and change Category Base HREF back to "/category"

4) Finally browse to /shopping once more to re-rebuild the ruleset with the original setting...

Hope this helps;

Cheers,
David.
--
PriceTapestry.com

Submitted by michael on Mon, 2012-10-08 08:09

Hi David thanks for the speedy response as always
when i try to change the href for category it doesn't change every time i save it doesn't change the href it just goes back to /category im also having a problem passing the values between pages, the ones i set up originally all work but when i try add more values passing via _GET it doesn't pass not sure if ive done everything right, i have all the values passing in the widgets but not across page

i added the values to pto_common around line 50 am i missing somthing there. heres the code

    $retval = get_bloginfo('url').$pto_config_productBaseHREF.pto_common_hyphenate($product->normalised_name).".html";
if (isset($_GET["fromdate"])) $retval .= "?fromdate=".$_GET["fromdate"];
if (isset($_GET["todate"])) $retval .= "&todate=".$_GET["todate"];
if (isset($_GET["nights"])) $retval .= "&nights=".$_GET["nights"];
if (isset($_GET["tcurrency"])) $retval .= "&tcurrency=".$_GET["tcurrency"];
if (isset($_GET["city"])) $retval .= "&city=".$_GET["city"];
if (isset($_GET["country"])) $retval .= "&country=".$_GET["country"];
if (isset($_GET["citycode"])) $retval .= "&citycode=".$_GET["citycode"];
if (isset($_GET["roomno"])) $retval .= "&roomno=".$_GET["roomno"];
if (isset($_GET["star"])) $retval .= "&star=".$_GET["star"];
if (isset($_GET["room"])) $retval .= "&room=".$_GET["room"];
return $retval;

it seems to pass everything up to tcurrency but nothing after.

Thanks,

Michael

Submitted by support on Mon, 2012-10-08 09:42

Hi Michael,

I'm not sure why the settings would not save, i've not come across that before but I would suggest de-activating and then re-activating PriceTapestry.org and see if that gives you back control of the settings.

Regarding your parameters not being passed through; it sounds like there is code elsewhere required for each additional parameter that has not yet been implemented. What I would suggest is searching each of pto.php, pto_search.php and pto_product.php for each instance of "tcurrency", and at each point; verify that you have similar, additional code in place for the parameters "city" through "room"...

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by michael on Mon, 2012-10-08 13:23

hi David,

i genrated the default file then reset price tapesry plugin but it didnt fix the problem with the category mapping also is the defaults supposed to come back one there own or do i have to replace them from file ?

thanks,

Michael

Submitted by support on Tue, 2012-10-09 07:42

Hi Michael,

I know you've been making some quite significant changes - perhaps if you'd like to email me the files relevant to this problem (I assume pto.php, pto_search.php and pto_product.php) I'll check them over and see if I can spot anything for you...

Cheers,
David.
--
PriceTapestry.com