I have tried this fix earlier mentioned [url]http://forum.cs-cart.com/showthread.php?t=15608[/url] , it doesn’t fix my problem. ok here it comes, i have a csv file with thousands of products, but the point is that for example the 1 product in the list can also appear on row 100, 200 and 1400, when i upload the csv it adds all categories that are listed but the product just appears in the last listed category. I have many thousand products in my listing so i cant go through them manually.
example: same product appears on three rows
row 1: category///category2///category3
row 200: category///category2///different category
row 3000: category///category100///category
ok all the categories adds but the product adds just to category:“category” when it should add to all of these three categories, it’s probably a small hack but i can’t find an solution on this. Stupid when it deletes the product from the category when it appears on next category, it should be like in Zen Cart where it adds the product in every category instead. Well i hope someone can help me
Thank you in advance!
Perhaps someone else can explain how CS-Cart handles things when the same product code is encountered multiple times during an import? I fear that it just overwrites the previous data each time, until you are left with only the last instance in the CSV.
I’d suggest making a test product, use the admin to add multiple categories, then export and see how that’s written in the CSV. Then, open your main CSV file in a spreadsheet, sort by Product Code, and set up just one instance of each product code with the multiple categories laid out per your test CSV.
I will caution you, some spreadsheets will unhelpfully format/style your data for you, creating a mess when you re-import. Highly recommended to run your edited data throught TextWrangler and force it back to plain text when you’re done. See this thread for some of the issues caused by NeoOffice “fixing” things unbidden!
Also, I feel your pain on the magnitude of that CSV file. I have just under a thousand product codes and that’s still a hassle to edit. Using a spreadsheet does help though, since you can hide columns that aren’t needed at the moment and sort.
I’m curious, but can’t you just have secondary categories during import?
cat1///subcat1;cat2///subcat2;etc
[quote name=‘gginorio’]I’m curious, but can’t you just have secondary categories during import?
cat1///subcat1;cat2///subcat2;etc[/QUOTE]
yes but it’s not the categories that are the problem, it’s when this import system deletes the product when it appears on many different rows, it only adds the product to the last mentioned category.
My csv looks like this, it adds all categories mentioned to the store but, product adds just to subcat555 because it deletes the product from subcat2 when it imports row 15000. it shouldn’t delete, just add the products, like Zen cart does.
*row 1
Product code
test product
Category
cat2///subcat2
Secondary categories
cat2///subcat2
*row 15000
Product code
test product
Category
cat333///subcat555
Secondary categories
cat333///subcat555
I have tried to configure the secondary categories like this to, no luck:
cat333///subcat555; cat333///subcat555
And yes i know that it would work if i configure the categories like this with the product code appearing just one time in the csv:
cat333///subcat555; cat222///subcat777; cat1///subcat2 etc.etc.
But this is not possible in my case, because i would have to manually assign every category then. it would take me months to go through
I really like this software and would like to have a couple critical things working if i could start using it for real, this is one of those issues. I hope someone can get the hang of this because it’s a bit difficult explaining this.
I think its because cs uses the product code as the inividual identfier in the database but some other carts use there own number system and keeps the product code seperate, so you couls have
database product no 1 with a product code of “shirt yellow”
dababase product no 2 with a product code of “shirt yellow” also in whatever category you like as the number used by the database is no 1 or no 2 etc. each time a new product is added then the number goes up sequentially, never to be overwritten again.
Cre loaded uses this system and it does make sense.
database number for system and your own product codes for us.
however afetr all my talk I have no answer for you as if CS cart is able to be changed to do this.
Sorry
John
Using product codes is a great idea for making sure you don’t end up with 9 different versions of the same product to hunt down if you need to make a chage to or delete a product.
I think the reason this method is frowned upon, is because it created redundant products. Imagine if the descriptions differed in the two entries … what happens then? Do they both get added? Does one overwrite the other?
The method you are suggesting is ONLY useful for moving products to multiple categories. It is useless for either adding products or for updating them. It is just asking for trouble.
That said, perhaps this might help. Copy this code:
```php
CSV Redundant category fixer
USAGE:
In your csv, make the first column the product code
- The second column your category
- The third colum the secondary categories
- The remaining columns can be left alone
Make the separator a semi-colon ";" and save the file.
Place the CSV in the same directory as this PHP file on the server.
Set the folder this file is in to 777.
Navigate to this file in a browser.
When it's finished, download the CSV and upload to CS-Cart
*/
echo "
Starting Process
\n";$updates= array();
$csv = false;
echo "
Locating the CSV file
\n";$files = scandir("./");
foreach ($files as $file) {
if (preg_match("/(.*?)\.csv$/", $file)) {
$csv = $file;
}
}
if (!$csv) { die("No CSV File Found in this Directory"); }
echo "
Found file: $csv
\n";echo "
Opening $csv
\n";$lines = file("$csv");
if (!$lines || count($lines) == 0) { die("Failed to open $csv or file is empty"); }
echo "
Processing File
\n";echo "
- \n";
- Updating: $product_code \n";
- Product Added: $product_code \n";
foreach ($lines as $line) {
$product = explode(";", str_replace("\"", "", trim($line)));
$product_code = $product[0];
$category = $product[1];
$secondary = $product[2];
if (isset($updates["$product_code"])) {
echo "\t
$updates[$product_code][2] .= $category . ";";
} else {
$updates[$product_code] = $product;
echo "\t
}
}
echo "
echo "
Finished updating csv
\n";echo "
Updating $csv
\n";$fd = fopen($csv, 'w');
foreach ($updates as $product_code=>$data) {
fwrite($fd, "\"" . implode("\",\"", $data) . "\"\n");
}
fclose($fd);
echo "
Finished
\n";echo "
Download $csv and open it in your favorite spreadsheet (this file is comma separated)
\n";?>
```
- Paste it into a file (update.php).
- Place the csv (semi-colon “;” delimtied) and the PHP file in the same directory on your server (i.e. /cscart/csv/).
- Change the folder permissions to 777.
- Navigate to the php file and watch the magic (if you get a “can’t open file” try changing the .csv permissions to 777).
Only run it once.
It will alter the csv to a comma delimited file and add the redundant categories as secondary categories.
Ta da! The magic of PHP.
In your .csv file, you have a column “Secondary Categories”, which is where you can put any other categories you want the product to appear in, i.e. product 1 appears in main category 1 but, if you also want it to appear in main category 2 and main category 3, include these two categories in the Secondary Categories column rather than the Categories column. You then only have one line in your .csv file and the product will only be updated once.
You cannot have the same part number or sku for more than one product if you are planning on using the import/export feature as only the last product in your list with that part number or sku will be updated and will overwrite any other products with the same part number or sku.
[quote name=‘Lyn’]In your .csv file, you have a column “Secondary Categories”, which is where you can put any other categories you want the product to appear in, i.e. product 1 appears in main category 1 but, if you also want it to appear in main category 2 and main category 3, include these two categories in the Secondary Categories column rather than the Categories column. You then only have one line in your .csv file and the product will only be updated once.
You cannot have the same part number or sku for more than one product if you are planning on using the import/export feature as only the last product in your list with that part number or sku will be updated and will overwrite any other products with the same part number or sku.[/QUOTE]
He has thousands of products and doesn’t want to edit them by hand. That’s why I provided the PHP file. It does this process automatically.
I’m with Lyn. I don’t know what you others are thinking.?
.csv
Product code | Category | Secondary category
12345 | Widgets | Whatchamacallits
Secondary category does not mean sub category under category. It’s any category in your category list.
How does your script above know what other categories he wants a product to show in? Maybe I am just not understanding what he is trying to do.?
[quote name=‘gginorio’]He has thousands of products and doesn’t want to edit them by hand. That’s why I provided the PHP file. It does this process automatically.[/QUOTE]
It can be done by importing a .csv file. You can also add more than one category under the Secondary Categories column.
The script looks for duplicate product codes. If a duplicate product code is found, it takes the category and places it in the secondary category column. If it finds another duplicate, it does the same thing. That way the primary and secondary categories are all in the same row and in proper format for CS-Cart import.
[quote name=‘gginorio’]Using product codes is a great idea for making sure you don’t end up with 9 different versions of the same product to hunt down if you need to make a chage to or delete a product.[/QUOTE]
Being searchable by product code and/or databse id is how this is solved.
John
[quote name=‘johnbol1’]Being searchable by product code and/or database id is how this is solved.
John[/QUOTE]
But then you have multiple products with the same SKU. Imagine invoicing, or tracking inventory or, worse yet, handling suppliers purchase orders.
[quote name=‘gginorio’]But then you have multiple products with the same SKU. Imagine invoicing, or tracking inventory or, worse yet, handling suppliers purchase orders.[/QUOTE]
Dont forget all the products and codes are the same identical, just in different cats thats all, I have numersous sites running this type of scirpt CRE Loaded to name 1 and no problems.
John
Before adding any new products, I use vlookup in Excel to check for duplicate part numbers. That way I can alter the new part number slightly (maybe add a letter or the brand name) so I don’t have the problem of duplicate part numbers when importing or updating prices using the import feature.
You cannot duplicate a product code. The software will not allow it. How many ever times the same product code shows up, the data in the last one will overwrite any previous.
[quote name=‘Tool Outfitters’]You cannot duplicate a product code. The software will not allow it. How many ever times the same product code shows up, the data in the last one will overwrite any previous.[/QUOTE]
Not sure with version 2, but with version 1 you can have duplicate product codes - the only time it causes problems is if you use the import feature to make any updates. If you are going to only alter and update your products manually, you are able to have duplicate codes.
I think it would get confusing having duplicate codes anyway. I have quite a few completely different parts that are sold with the same part number.
Ok i see that this has got a few answers, thats nice But i still have no clue how to get this working. if i have 10 products with the same product number, i want it to add the same values to all of those such as stock inventory, description etc. except the categories, they should be different. And when a customer buys one piece, it should decrease the inventory in every category where the product appears, same goes for description, if i change it in admin on one product it should automatic change the 9 others too. Zen cart does this all, it should be possible.
[QUOTE]I think the reason this method is frowned upon, is because it created redundant products. Imagine if the descriptions differed in the two entries … what happens then? Do they both get added? Does one overwrite the other?
The method you are suggesting is ONLY useful for moving products to multiple categories. It is useless for either adding products or for updating them. It is just asking for trouble.
That said, perhaps this might help. Copy this code:
Code:
CSV Redundant category fixer
USAGE:
In your csv, make the first column the product code
- The second column your category
- The third colum the secondary categories
- The remaining columns can be left alone
Make the separator a semi-colon ";" and save the file.
Place the CSV in the same directory as this PHP file on the server.
Set the folder this file is in to 777.
Navigate to this file in a browser.
When it's finished, download the CSV and upload to CS-Cart
*/
echo "
Starting Process
\n";$updates= array();
$csv = false;
echo "
Locating the CSV file
\n";$files = scandir("./");
foreach ($files as $file) {
if (preg_match("/(.*?)\.csv$/", $file)) {
$csv = $file;
}
}
if (!$csv) { die("No CSV File Found in this Directory"); }
echo "
Found file: $csv
\n";echo "
Opening $csv
\n";$lines = file("$csv");
if (!$lines || count($lines) == 0) { die("Failed to open $csv or file is empty"); }
echo "
Processing File
\n";echo "
- \n";
- Updating: $product_code \n";
- Product Added: $product_code \n";
foreach ($lines as $line) {
$product = explode(";", str_replace("\"", "", trim($line)));
$product_code = $product[0];
$category = $product[1];
$secondary = $product[2];
if (isset($updates["$product_code"])) {
echo "\t
$updates[$product_code][2] .= $category . ";";
} else {
$updates[$product_code] = $product;
echo "\t
}
}
echo "
echo "
Finished updating csv
\n";echo "
Updating $csv
\n";$fd = fopen($csv, 'w');
foreach ($updates as $product_code=>$data) {
fwrite($fd, "\"" . implode("\",\"", $data) . "\"\n");
}
fclose($fd);
echo "
Finished
\n";echo "
Download $csv and open it in your favorite spreadsheet (this file is comma separated)
\n";?>
- Paste it into a file (update.php).
- Place the csv (semi-colon ";" delimtied) and the PHP file in the same directory on your server (i.e. /cscart/csv/).
- Change the folder permissions to 777.
- Navigate to the php file and watch the magic (if you get a "can't open file" try changing the .csv permissions to 777).
Only run it once.
It will alter the csv to a comma delimited file and add the redundant categories as secondary categories.
Ta da! The magic of PHP.[/QUOTE]
This might by the way be the solution to my problem,but i can't get it to work :( csv saved with semicolon and permissions 777, no warning messages. Looks like this in browser:
[HTML]/* CSV Redundant category fixer USAGE: In your csv, make the first column the product code - The second column your category - The third colum the secondary categories - The remaining columns can be left alone Make the separator a semi-colon ";" and save the file. Place the CSV in the same directory as this PHP file on the server. Set the folder this file is in to 777. Navigate to this file in a browser. When it's finished, download the CSV and upload to CS-Cart */ echo "
Starting Process
\n"; $updates= array(); $csv = false; echo "
Locating the CSV file
\n"; $files = scandir("./"); foreach ($files as $file) { if (preg_match("/(.*?)\.csv$/", $file)) { $csv = $file; } } if (!$csv) { die("No CSV File Found in this Directory"); } echo "
Found file: $csv
\n"; echo "
Opening $csv
\n"; $lines = file("$csv"); if (!$lines || count($lines) == 0) { die("Failed to open $csv or file is empty"); } echo "
Processing File
\n"; echo "
1. \n"; foreach ($lines as $line) { $product = explode(";", str_replace("\"", "", trim($line))); $product_code = $product[0]; $category = $product[1]; $secondary = $product[2]; if (isset($updates["$product_code"])) { echo "\tUpdating: $product_code
2. \n"; $updates[$product_code][2] .= $category . ";"; } else { $updates[$product_code] = $product; echo "\tProduct Added: $product_code
\n"; } } echo "
\n"; echo "
Finished updating csv
\n"; echo "
Updating $csv
\n"; $fd = fopen($csv, 'w'); foreach ($updates as $product_code=>$data) { fwrite($fd, "\"" . implode("\",\"", $data) . "\"\n"); } fclose($fd); echo "
Finished
\n"; echo "
Download $csv and open it in your favorite spreadsheet (this file is comma separated)
\n"; ?>[/HTML]
[quote name=‘jephep’]if i have 10 products with the same product number, i want it to add the same values to all of those such as stock inventory, description etc. except the categories, they should be different. And when a customer buys one piece, it should decrease the inventory in every category where the product appears, same goes for description, if i change it in admin on one product it should automatic change the 9 others too. Zen cart does this all, it should be possible. [/QUOTE]
It seems to me you don’t actually want ten products but just the one product in ten different categories, in which case you have the one main category and all the other nine categories should be listed under the Secondary Categories heading in your .csv.
I suggest you create a test product - add it to one of your main categories. Under the Secondary Categories section, click on “Add Categories” and tick the boxes of all the other categories you want to list this one product in.
Then export that product to a .csv file. This will give you the layout for the Secondary Categories (in Version 1.3.5 they are just separated by semi-colons but I’m not sure about Version 2). Then you can create your .csv file for all the other products and import it.
If you only want the one product in different categories, this is the way to do it and, once you get the hang of it, it should be fairly quick.
That way any changes you make to the one product will be updated in all your categories as you are only working with one product, not ten.
You can have as many secondary categories as you want to.
Hope this is what you are after.