Jump to content

Upload 1 product to 2 categories via .CSV


Recommended Posts

Hi there, is there a special way to express two or more shop categories, such that when l upload 1 product via CSV, on the same row, those multiple categories are mentioned, and thus the product is listed under those multiple categories simultaneously?


Currently, my upload .csv states:

Category1, Category2


This leads to the uploaded item being without any category, because the category is being inferred as one string: "Category1, Category2"

Update: according to my notes, multiple categories are indeed to be comma separated.


So where am i going wrong?


Should l have written: Category1,Category2

instead of: Category1, Category2


? i.e. should there be zero spaces after the commas?

Thing is, the images are also not being recognised in my .csv upload - yet they are actually written with zero spaces after the commas, e.g.:




So, it appears that commas are just not liked. Could it be that because it's a comma separated spreadsheet, something is going awry with my use of commas within the spreadsheet?

Edited by cubicsquare
Link to comment
Share on other sites

Hi there, here's an example of how it is appearing in the text editor version of the .CSV, including the speech marsk:

"Good stuff, drink & chairs,Fantastic stuff: For the fridge / freezer"


The 2 categories are:

Good stuff, drink & chairs

Fantastic stuff: For the fridge / freezer


Obviously, the comma within the title of that first category is messing my day up.

But it seems also the "/" symbol in a category title is fracturing the category names into pieces too!





In the PRODUCT INVENTORY of my control panel, l am only seeing the PRIMARY CATEGORY listed. That is the first category mentioned in the string of categories. I was expecting to see multiple categories listed right under each product's name in the product list view, rather than just the primary category. When you go to the product's own category tab, you can change the primary category there.


In tandem with this quirk, of course, l did not realise my categories had commas and forward slashes, and l certainly didn't realise forward slashes were causing category names to fracture just as commas were too, within the category name.





Do you think l should try uploading the multiple image URLs per product, with a space after the commas?

Edited by cubicsquare
Link to comment
Share on other sites

CubeCart may or may not see the forward slash as a category tree delimiter. That is, such as, electronics/televisions/accessories/remote-controls. From my understanding of CubeCart's code, declaring the actual "seo friendly" phrase is fairly free-form. (Do not use quotes.)

The product import code uses PHP's fgetcsv() function, which I have to assume is coded to trim off whitespace that may appear in front of or following the intended text (that is, fgetcsv() includes a trim() function).

However, as for splitting image names, category names, etc, by the column's embedded commas, I see that CubeCart uses a trim() function on the resulting array of elements. So, no worries there.


Link to comment
Share on other sites

Hi there @bsmither

I can now confirm:

1. CubeCart's inventory upload system doesn't immediately show that the categories have also been uploaded. For a brief while it shows that most of the uploaded products have no categories. Then, after a while, it is revealed that they all have their attached categories, but it appears as if they have only one category per product, even though l may have uploaded multiple categories per product. On drilling down into a product's actual categories tab, it is then revealed that the multiple categories have indeed been recognised, but only the first category in the string is showing in the product list on the control panel. This is designated primary category via a radio button on the aforementioned category tab for that product.

Very rough trip.


2. Ok this is where it gets really upsetting.

I have tried the following versions for the images field when aligning my upload spreadsheet contatenated image URL column with CubeCarts "Images (Comma Separated)" heading:


VERSION 1: https://store.mysite.com/images/source/catalogue124/02.jpg,https://store.mysite.com/images/source/catalogue124/04.jpg,https://store.mysite.com/images/source/catalogue124/05.jpg

VERSION 2: https://store.mysite.com/images/source/catalogue124/02.jpg, https://store.mysite.com/images/source/catalogue124/04.jpg, https://store.mysite.com/images/source/catalogue124/05.jpg



Neither of these versions causes a set of 3 images to appear for the product listing. I have had a CubeCart shop with all my inventory successfully, cleanly listed before. That was a work in progress and l abandoned it because l got sidetracked. I deleted it all and started again with the present revised inventory. Yet this time, bizarrely, no images are uploading. I believe l'm expressing the string of multiple image URLs the same as ever, or rather, "VERSION 1" was how l always uploaded my multiple images per product, and l never had a problem before. What gives?

By the way, the URL names have been changed to protect the innocent. Be assured that each individual URL does load an image successfully. But when l upload a string of 3 images via matching my CSV spreadsheet colum to CubeCart's "Images (Comma Separated)" heading, l get no pics uploaded. As l say, l'm sure it used to work before.


Link to comment
Share on other sites

Update: I am wondering if the skin i'm using - the Foundation skin - has somehow been revised, and is only permitting images that are cached in a folder specific to the skin?

I wonder this because this is the URL for the placeholder image that l get instead of the intended product images:




Sure, that's just the placeholder image, but l do wonder if all of my ad images were meant to go in that parent "foundation/images" folder, if l'm using the Foundation skin? But l'm sure it never used to be like that. I really doubt this is the real issue.

Link to comment
Share on other sites

"only the first category in the string is showing in the product list [in admin]"

Correct. The first category in the CSV import is presumed to be the 'primary' category, and only the primary category is displayed in admin, Product Inventory list.

An image is a page resource, and that image can exist anywhere on the Internet - the src attribute just needs to point to it.

If CubeCart determines that the use of noimage is necessary, it is because there are no intended images assigned to the product.

I will look at the import code as regards getting images assigned.

Link to comment
Share on other sites

For your collection of images in the CSV file, please use this specific format (it is assumed this text string is enclosed in quotes - as shown - as it exists in the CSV file):


CubeCart will insist that images (with sub-folder path) mentioned in this string must eventually exist in /images/source/. Thus, only that distinctive part of the path/name can be allowed.

Until Github issue #2923 is solved, do not have spaces following the commas, and do not use leading periods.

  • Like 1
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.

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...