Author Topic: Updating/Inserting categories via CSV file  (Read 4740 times)

Offline castigous

  • Newbie
  • *
  • Posts: 44
  • Karma: +3/-0
    • View Profile
Updating/Inserting categories via CSV file
« on: June 07, 2017, 06:19:56 PM »
Hi!

Since I haven't had an answer to my topic since last friday --maybe because I added too many sub-topics to it in the late questions. I decided to post in separate topics.

Lately what I wanted to do was to update the products already in the database with additional categories --because almost all products belong to many categories (usually up to 3) and not just one.

So I analized the exported CSV file of a products which I added manually and had these 3 categories, and saw that the categories are expressed as these columns:

products.product_id
products_to_categories[1].product_id (same number that in "product.product_id")
products_to_categories[1].category_id (additional category 1)
products_to_categories[2].product_id (same number that in "product.product_id")
products_to_categories[2].category_id (additional category 2)
products_to_categories[3].product_id (same number that in "product.product_id")
products_to_categories[3].category_id (additional category 3)

But I get an error message, no matter if have the 1st column action set as update or as insert:
"
Total loaded: 6594. Updated: 0. Created: 3035. Errors: 3559
There are some errors. Show details
Warning: Update products. All columns are keys, update action is not allowed. Please use insert.
"

I tried with a CSV that had update in al cells of the 1st columns action.

Then I tried with a CSV that had insert in all cells of the 1st columns action.

I attach samples of both options.

Thanks!

Offline eCommerce Core

  • Administrator
  • Hero Member
  • *****
  • Posts: 1602
  • Karma: +93/-1
    • View Profile
Re: Updating/Inserting categories via CSV file
« Reply #1 on: June 09, 2017, 10:45:16 PM »
I think your problem that count starts from [1] and should start from [ 0 ]
Code: [Select]
products_to_categories[0] should be first.

See attached file that does work.
“If you’re in the luckiest one per cent of humanity, you owe it to the rest of humanity to think about the other 99 per cent.”
― Warren Buffett

Offline castigous

  • Newbie
  • *
  • Posts: 44
  • Karma: +3/-0
    • View Profile
Re: Updating/Inserting categories via CSV file
« Reply #2 on: June 10, 2017, 01:05:53 PM »
Thanks!

Since this is an update, I didn't included this variable assuming that since every product already has this 1st category fulfilled (represented by the column products_to_categories[0]).

All i need is to add more categories to the 1st one. So I guessed that the CSV file wouldn't need to include every column that is already fulfilled.

Is this a wrong assumption?

Do I need to include every column also for updates?

Also which of the two files I attached is the correct one to use for this, the one with 'update' in the action column or the one with 'insert'?

Thanks!

Offline castigous

  • Newbie
  • *
  • Posts: 44
  • Karma: +3/-0
    • View Profile
Re: Updating/Inserting categories via CSV file
« Reply #3 on: June 10, 2017, 01:26:06 PM »
Hi!

Since it seems that the CSV file needs all columns even for updating, I tried to import by adding just 5 columns to a CSV exported by AC almost untouched -I only added the action columns with 'update' in each product I need to update, and added the info (2-digit numbers ) for these columns which were blank in the CSV file exported by AC:

products_to_categories[1].product_id
products_to_categories[1].category_id
products_to_categories[2].product_id
products_to_categories[2].category_id

I kept every othe column untouched and the resulting CSV file is about 692K.

But now I get this error:

There has been a critical error processing your request
Please check AbanteCart and webserver error logs for more details. You can check error log in the control panel if it is functional. Otherwise, refer to error log located on your web server


Report this problem to AbanteCart team (do not change email subject)


AbanteCart Troubleshooting Guide

Go to main page
Project Homepage|Documentation|Support Forums|Marketplace



My php.ini for AC folder has this:

session.gc_maxlifetime = 12000000
magic_quotes_gpc = Off
safe_mode = Off
memory_limit = 300M
max_execution_time = 259200
default_charset = "UTF-8"
upload_max_filesize = 200M
session.use_trans_sid = Off
session.use_cookies = On
register_globals = Off
mysql.connect_timeout = 20
zend_extension=/usr/local/php55/lib/php/extensions/ioncube.so
zend_extension=/usr/local/php55/lib/php/extensions/ZendOptimizer.so


What is the problem?

I attach a sample of 6 products of this file.

Thanks

Offline jsitges

  • Newbie
  • *
  • Posts: 8
  • Karma: +3/-0
    • View Profile
Re: Updating/Inserting categories via CSV file
« Reply #4 on: August 15, 2017, 12:54:06 PM »
I have the same problem.

I dont think
  • needs to be first or that all the columns need to be there, I just dont think its possible from the way its coded.  I really hope a dev can come in and clarify.


I am trying to insert new categories to already existing products, I get the same error "use insert, all products are keys"

SOLUTION:

add an updatable parameter. 

I added price to my update csv, and tada!

HOPE THIS HELPS.

Offline Tabergabea

  • Newbie
  • *
  • Posts: 1
  • Karma: +0/-0
    • View Profile
    • 15 Popular Sex Cam Sites
Re: Updating/Inserting categories via CSV file
« Reply #5 on: August 25, 2017, 04:31:52 PM »
I have the same problem.

I dont think
  • needs to be first or that all the columns need to be there, I just dont think its possible from the way its coded.  I really hope a dev can come in and clarify.


I am trying to insert new categories to already existing products, I get the same error "use insert, all products are keys"

SOLUTION:

add an updatable parameter. 

I added price to my update csv, and tada!

HOPE THIS HELPS.

Ah this is what I was looking for! Appreciate you sharing your solution.

 

Powered by SMFPacks Social Login Mod