You are here:  » category name contains invalid characters


category name contains invalid characters

Submitted by george-p on Tue, 2013-04-16 16:56 in

Hello David, im new to pricetapestry and very excited i purhase it

i have some problems

1. at category mapping, i cant put name with greek characters , • category name contains invalid characters

2. i tried name case filter and also dosent works with greek characters, maybe greek characters dont work with other filter too, didnt try it

3. at categories page, the letter heading show a strange character if categories are with greek character {link saved}

4. how can i import products with same name? unique field for each product is product name? can make it to be unique field the product id ?

thanks

Submitted by support on Tue, 2013-04-16 17:12

Hello George - thank you for your comments and welcome to the forum!

Re: 1/
This is actually to do with legacy code, but it is now safe to use Greek and other characters in your Category Mapping master names. To change this, edit admin/categories.php and look for this code at line 20:

if(!preg_match("/^[0-9a-zA-Z\. ]{0,255}$/",widget_posted($_POST["name"])))

...and REPLACE with:

if(FALSE)

That will remove the check completely, and you will have no restrictions on category name.

Re: 2/

This is a new one! OK, the Name Case filter needs to be modified to use the multi-byte version of PHP's string handling functions. To do this, edit includes/filter.php and look for this code at line 125:

  return ucwords(strtolower($text));

...and REPLACE with:

  return ucwords(mb_strtolower($text));

Re: 3/
Same issue as above, the multi-byte version of substr() is required... To do this, edit html/atoz.php and look for this code at line 15:

  $firstLetter = strtoupper(substr($item["name"],0,1));

...and REPLACE with:

  $firstLetter = mb_strtoupper(mb_substr($item["name"],0,1));

Re: 4/
Yes, you can do this but first you would need to add a new field to your site so that you can register and import a unique ID for a product, for example a `uid` field. This would be done following the instructions here.

Also, you might be interested in yesterday's post here regarding mapping by a unique ID if you have more than one merchant using common ID fields

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by george-p on Tue, 2013-04-16 17:51

thanks for your super fast support :)

Submitted by george-p on Wed, 2013-04-17 17:06

Hello again

i tried the changes

1. works fine now

2. still not work ,if apply the filter then all categories renamed to first letter only all other letters removed

3. still not working {link saved}

4. i added the uid filed to add unique field for each product, how i can make that field to be the unique and import products with same name ?

Submitted by support on Wed, 2013-04-17 17:58

Hello George,

Re: 2/ 3/,

Please could you let me know your Price Tapestry installation URL and the filename of the feed containing these categories (I will remove before publishing your reply) and I will download them to my test server and check this out for you with the same data.

Re: 4/
Having added the unique field, you can then use the Automatic Product Mapping By UID scripts.

Cheers,
David.
--
PriceTapestry.com

Submitted by george-p on Wed, 2013-04-17 19:28

2/ 3/,

because greek characters was wrong at database, i added at includes/database.php before the closing PHP tag: database_queryModify("SET NAMES 'utf8'",$result); , i tried and with out this but still 2-3 dont work

4. i dont want automatic mapping , i want to be able to import products with the same nanme , i found the solution with the text after but cant do this because dont have any field with colour or something else, isn't possible to import products with the same name?

thanks

Submitted by support on Thu, 2013-04-18 08:30

Hello George,

Thanks for the links, I've got it all working on my test server. The main problem was because PHP is using ISO-8859-1 internally, so the optional charset parameter must be passed to the multibyte string functions.

However, there is no mb_ucwords() function, but since there are mb_substr() and mb_strtoupper() functions it's easy enough to do it manually!

Following on from the modifications described above, you will now have in includes/filter.php the following code 125:

    return ucwords(mb_strtolower($text));

REPLACE this with:

    global $config_charset;
    $text = mb_strtolower($text,$config_charset);
    $words = explode(" ",$text);
    $newWords = array();
    foreach($words as $word)
    {
      $first = mb_substr($word,0,1,$config_charset);
      $rest = mb_substr($word,1,-1,$config_charset);
      $newWords[] = mb_strtoupper($first,$config_charset).$rest;
    }
    return implode(" ",$newWords);

Finally, $config_charset also needs to be used in the modification to html/atoz.php, where at line 15 you will now have:

  $firstLetter = mb_strtoupper(mb_substr($item["name"],0,1));

...REPLACE with:

  $firstLetter = mb_strtoupper(mb_substr($item["name"],0,1,$config_charset),$config_charset);

Re: 4/

If you want to permit import of duplicate products from the same merchant, this can be done easily simply by dropping the UNIQUE index on the dupe_hash field. To do this, create and run the following dbmod.php script (it only needs to be executed once), and then re-import;

<?php
  
require("includes/common.php");
  
$sql "DROP INDEX dupe_filter ON `".$config_databaseTablePrefix."products`";
  
database_queryModify($sql,$result);
  print 
"Done.";
?>

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by george-p on Thu, 2013-04-18 11:21

works perfect now

4. to do this dont need to add unique product id right ?

i DROP INDEX dupe_filter and now imports all products and,and shows product with same name at Stockist
http://localhost/price/products.php?q=X%CE%B1%CE%BC%CE%B7%CE%BB%CE%AC+Sneakers+Nike+AIR+MAX+90+ESSENTIAL

at search results shows only one of the products with the same name, how i can show them all at results ?

Submitted by support on Thu, 2013-04-18 11:49

Hi George,

Glad you're up and running!

By default, search.php does GROUP BY search_name, so you will only see one result per product, but you can easily remove this (the SQL does require a GROUP clause since it is a summary query). If you edit that file, and use your text editor's Search and Replace function to make the following change;

Search:

GROUP BY search_name

Replace:

GROUP BY id

No need to re-import after this change at all...

Cheers,
David.
--
PriceTapestry.com

Submitted by george-p on Thu, 2013-04-18 17:51

works fine now thanks

1 more question , script will work at {host saved} server ?

Submitted by support on Thu, 2013-04-18 18:14

All you need is PHP and MySQL. Basic shared hosting accounts offer this as standard; VPS accounts normally include a control panel that will set-up domain names just as easily as if they were a shared hosting account with PHP and MySQL support, and if on a dedicated server or cloud server then you have full control over your server and can therefore set it up as required! If you're not sure, just let me know...

Cheers,
David.
--
PriceTapestry.com

Submitted by george-p on Thu, 2013-04-18 21:09

ok thanks