Using Productid In Csv Product Upload

Hello,



How can I “force” cs-cart (version 4) to use the productID which is provided in the csv file used to upload new products?



Right now it seems cs-cart is ignoring the value given in the csv file.





Regards Mirco

I don't know why you would want to but it is auto generated in the data base. I suppose you could disable the auto generation in the data base.?

Hi,



It is related to my other question:

Import Product Options - How? - General Questions - CS-Cart Community Forums



I need to import products wich have different sizes with stock.

So -as far I understand at this moment- I need to upload two files: 1 with product information to import the general products and a second file with the product options and their stock level. (on the second tab of product import)

But in the second file you need (mandatory) to give the productid wich I don't know because it is 'auto generated' when importing the first file.



Hope you understand my question better know.



gr Mirco

I think you mean the “product code”. The product_id is an auto-increment value in the DB itself and should not be used for import/export.

Hi all,



First a thank you for taking the time for answering my questions. :grin:



Ok, if I’m not using the “product ID” how can I upload the second file with the product options & their stock ?

(in the second tab of product import in the backend)

If I’m importing new products how do I know the “product ID” which is mandatory in the import?



Please help me in the wright direction because I’m already trying to figure this one out for weeks now…



(BTW: Using cs-cart 4.0.2)

There are two ID's in cs-cart for products. product_id which is the database generated auto-increment value which you should NOT use in import/export. There is also the product_coe which should represent the product that you want to reference using your own naming.

Be careful though because product_code is not a unique value in the DB since the product can be in multiple companies with different properties.

Hi,



Product id export is available in 4.0.3, but if you cannot find this field, I made an add-on for exporting product id.

You can download for free. Just copy the folder’s content to the /app/addons folder of your installation, and enable it via Add-on manager.



Regards,



Istvan


[quote name=‘Mirco’ timestamp=‘1389533548’ post=‘174960’]

Hi all,



First a thank you for taking the time for answering my questions. :grin:



Ok, if I’m not using the “product ID” how can I upload the second file with the product options & their stock ?

(in the second tab of product import in the backend)

If I’m importing new products how do I know the “product ID” which is mandatory in the import?



Please help me in the wright direction because I’m already trying to figure this one out for weeks now…



(BTW: Using cs-cart 4.0.2)

[/quote]

[quote name='tbirnseth' timestamp='1389565125' post='174986']

There are two ID's in cs-cart for products. product_id which is the database generated auto-increment value which you should NOT use in import/export. There is also the product_coe which should represent the product that you want to reference using your own naming.

[/quote]



Ok, this I understand.

Leaves the question still: How do I upload NEW products with their sizes (product options) and stock per size?



Example:

T-shirt with print

Size: S 10x, M 5x, L 6x, XL 7x, XXL 10x

Etc etc



Thank you

[quote name='Mirco' timestamp='1389793442' post='175200']

Ok, this I understand.

Leaves the question still: How do I upload NEW products with their sizes (product options) and stock per size?



Example:

T-shirt with print

Size: S 10x, M 5x, L 6x, XL 7x, XXL 10x

Etc etc



Thank you

[/quote]



Hi, did you find an answer for this yet? I have the same question.

No unfortunately not.

Problaby a very difficult question…

Don’t know why because this is one of the first things I ran into when transferring my old webshop to this one. So I’m sure I’m not the first one who ran into this.

Gives me a haedache though… :shock:

I don't use it so I'm just talking off the top of my head here…



But if you create the items as options with their own product codes, won't the import deal with those products? It “should” first look in the products table for the item and update that. If not there, it should update the inventory data related to the product_code and then update the parent product with the other data.



But that's a “should”.

Hi, yeah that should be but it isn't.



So far it is not possible to import new products with product options and stock. To bad.

If you import new products it will assign new productID to it so you don't know the productID's for the product options wich you need when uploading product options.

I am running into a problem with this on my migration from 3.x to 4.x. When I export products from 3.x (no product_id) then in import into 4.x, it assigns a new product_id number. The problem is, when I Import the orders and order_data, it keys the products in each order by product_id which means all of the products are jumbled.

Generally the easiest way to determine the import format is to create a product (with or without option combinations) how you want it and then do an export. You can then use that row to determine the format of the data. I don't think you can create option combinations for NEW products since there's nothing to reference for their creation.

there is a simple way to add Product ID to the feed on the old version. Just open the schemas/exim/products.php file and add:

'Product ID' => array (
    'db_field' => 'product_id'
),

after the following code:

'Product code' => array (
	'db_field' => 'product_code',
	'alt_key' => true,
	'required' => true,
),

Then clear cache and check the result

My problem is the import. 4.x lists product_id as an import field but it replaces it with new auto-generated ones. This screws up the links to products in the imported orders.

I did some testing with the database, an insert which includes product_id will override the default auto-increment for product_id. Just need to figure out how to modify the import in 4.x to insert the product_id. It seems to have some provisions for it, just does not work.

This is interesting...

'import_process_data' => array(
'unset_product_id' => array(
'function' => 'fn_import_unset_product_id',
'args' => array('$object'),
'import_only' => true,
),
in 4.x
/app/schemas/exim/products.php

It's a chicken/egg problem. A new product is created with an INSERT which generates a product_id (primary key of the table).

I "think" (but have not confirmed) that when you use a product_id field on import, if the product_id doesn't exist, it is ignored.

This is a guess and not confirmed. At least that's how I'd do it from a DB integrity standpoint.

This is interesting...

'import_process_data' => array(
'unset_product_id' => array(
'function' => 'fn_import_unset_product_id',
'args' => array('$object'),
'import_only' => true,
),
in 4.x
/app/schemas/exim/products.php

You can delete this part of code. But please note that in this case the database should not contain product IDs from the feed before import