Hello David,
i hope this is now my last question.
Following:
I have more then One Million products in my databese and the categories in the feeds are very confused. I cant do it with the categorie mapping, because for 10.000 products i need at least one day.
Isn´t it possible in the filter to search in the title(name) for a word like "Mainboard" and set in the database in the "categories" for example "Computer > Mainboards".
Now i can only search in one feed field and replace this word i´d search for.
I hope you understand my bad english and you can help me.
Also thanks for your last replay, must change the code, but now it works.
Thank you and Cheers, Peter
Hello David,
just a good idea, but one feed has over 10.000 products with different categories, like Computers, Mobile Phones, Cars, Games ...
So i can´t do this.
Now i have a .CSV Editor, but it´s just a hard work too to find and replace the categories.
But nothing matters, if this isn´t possible, i must work for a long time :)
And if i had a solution, i´ll post it here.
Cheers, Peter
Hello again,
now i got the right sql querry...
UPDATE `products`
SET `category` = 'Computer > Hardware > Mouse'
WHERE `name` LIKE CONVERT( _utf8 '%Mouse%'
USING latin1 )
COLLATE latin1_swedish_ci
But my problem is now, how i can paste this in my admin.php that i must not open every time my database.
I whant a field where i write the search string and a drop down menu where i can select the category.
Please help me and thanks a lot, Peter
Hello Peter,
Are you trying to write a separate admin script that you go to once you have imported all your products, and then enter search strings and get it to set the category from the drop down menu?
~ or ~, do you want this to happen automatically every time your import from stored search strings and categories?
Cheers,
David.
Hello David,
mhhh :)
an automatic import isn´t bad, but than i need to save all "search-words" and the new "categories" in the database. And i must also need to change some products after the atomatically change, because some products have the same name, but another category. For example:
Search word: Mouse
Result Computer-Mouse = Category "Computer..."
Result The Mouse on the moon = Category "Book..."
If this is too complicated i´ll take your first idea, with enter search strings and set the category from the drop down menu.
Thanks, Peter
Hi Peter,
Call this script setcat.php in your /admin/ folder:
<?php
require("../includes/common.php");
require("../includes/widget.php");
$categories["Test"] = "Test";
$categories["Computer > Hardware > Mouse"] = "Computer > Hardware > Mouse";
$categories["Computer > Hardware > Keyboard"] = "Computer > Hardware > Keyboard";
$categories["Computer > Hardware > Graphics"] = "Computer > Hardware > Graphics";
if ($_POST["search"])
{
// $sql = "UPDATE `products` SET `category` = '".database_safe($_POST["category"])."' WHERE `name` LIKE '%".database_safe($_POST["search"])."%'";
$sql = "UPDATE `products` SET `category` = '".database_safe($_POST["category"])."' WHERE `name` LIKE CONVERT( _utf8 '%".database_safe($_POST["search"])."%' USING latin1 ) COLLATE latin1_swedish_ci";
database_queryModify($sql,$affectedRows);
header("Location: setcat.php");
exit();
}
require("admin_header.php");
require("admin_menu.php");
print "<h2>Set Categories</h2>";
print "<form method='post'>";
print "Search (in product name):<br />";
widget_textBox("search","");
print "<br /><br />";
print "Set Category:<br />";
widget_selectArray("category",$categories,"","");
print "<br /><br />";
print "<input type='submit' value='Submit' />";
print "</form>";
require("admin_footer.php");
?>
Notice that I've included your SQL (which didn't work on my server) in there - the one I used is commented out.
Secondly, as the script stands you cannot use ">" in the category name, as it is normalised so characters like that are removed. If you want to have category names like that, you must change Line 4 of search.php to the following:
$q = (isset($_GET["q"])?tapestry_normalise($_GET["q"],">:\."):"");
The only change is to add ">" to the list of allowed characters as used by the tapestry_normalise() function. Then it should work.
Cheers,
David.
Sry David, but it dosn´t work.
i get following error:
Parse error: syntax error, unexpected '{' in /home/.sites/116/site454/web/admin/setcat.php on line 8
And if i commented the "{" out i get following error:
Parse error: syntax error, unexpected T_VARIABLE in /home/.sites/116/site454/web/admin/setcat.php on line 10
^^ This is the SQL and i get the error on both (yours and mine)
Any idea?
Cheers, Peter
Hi Peter,
It works fine here - can you post the exact code as you have it; it may be related to any changes that have been made to the $categories array.
Unexpected { often means a missing ; from the end of a previous line...
Cheers,
David.
Sry, it was my fault.
I forgot a ;
Thank you very much David
Cheers, Peter
Hello Peter,
I think in this scenario if the categories in your feeds are bad; it is best not to use them and import each feed into a single category.
On the Feed Registration Page (Step 2) you can simply type a category name rather than using a field from the feed.
If you have enough feeds and make your categories suitably broad (for example just "Computers") then it should still make for a good looking site.
Cheers,
David.