Jump to content

Resolved - How to add multiple categories to a product upload


Man_

Recommended Posts

In Excel??? To be imported as a CSV by phpMyAdmin to the CubeCart_category_index table?

 

The index_table structure is such that:

cat_id: numeric value of the id number of the category

product_id: numeric value of the id number of the product

primary: 1 if this category is the product's main category, 0 otherwise

 

So, if you start with a spreadsheet of all categories (and their names), you can then flood-fill the product_id column with the product_id.

Link to comment
Share on other sites

Hello Smither,

I am going to upload the products via import on the back end, the only problem I have is that I want to give one product a main category number and also add that same product to a different category with another number, is it only one number allowed and also the product code, If i am uploading via import how can I get a auto generated product code?

Thank you Smither.

Link to comment
Share on other sites

Even though there is a column 'cat_id' in the 'CubeCart_inventory' table, I have come to believe not all of CubeCart will use it (not even as a fallback if no records are found in the 'CubeCart_category_index' table).

 

That said, CubeCart uses 'category_index' to associate the item's primary category and all other secondary categories. The only way you would know what the product_id of imported products will be beforehand, is to have a column 'product_id' in the file to be imported, with a number higher than the highest number used so far in the 'inventory' table. Then you can import a second file as discussed above.

 

phpMyAdmin's file import feature may have a setting (or an 'understanding') that if a column is given in the file that would other wise auto-increment, then tell the database to switch off the auto-increment function as use the value given. But then be sure to not allow a condition to happen known as "Duplicate key for index."

Link to comment
Share on other sites

Hello Smither,

 

I am not talking about the phpadmin, In microsoft's Excel right, the product code is left blank so when I go to import via the admin panel it doesnt automatically generate a product code, though i would like it to.

 

please see image below.

 

thank you very much

Link to comment
Share on other sites

Ok.

 

I don't have a CSV file prepared, so this is just an experiment for you to try.

 

In the file /admin/sources/products.import.inc.php, near line 150, find:

// Insert if we have a product record with at minimum a value for the product name
if (isset($product_record) && !empty($product_record) && !empty($product_record['name'])) {
  $product_record['date_added']    = $now;

Above the last line of what's shown above, add this line:

  if (empty($product_record['product_code'])) $product_record['product_code'] = generate_product_code($product_record['name']);

This says, if there is no product_code that was processed in the the line of the CSV just read, generate one from the name given and assign it to product_code.

 

The product code generator is the same one used by CubeCart if, when adding a new item manually, you select "Auto-Generate Product Code".

 

And, this is for CC52X - I haven't examined how/if this would work in CC515 or earlier.

 

Also, I think I see how one can add secondary categories to an imported record. I'll look into that later.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...