Wholesaler inventory import plugin

  • Posts: 128
  • Thank you received: 3
7 years 1 month ago #264293

-- HikaShop version -- : 2.6.3
-- Joomla version -- : 3.6.5
-- PHP version -- : 5.3.24

I work with a wholesaler that provides their inventory in csv files for download. Every morning at a set time they update their inventory file and every 10 minutes they update their inventory quantity file. Is it possible to create a plugin to use the cron to once a day import and overwrite the inventory file and for each item that does not have a quantity of 0 create products into specific categories based on the description of the item in the csv file? If so, I would also like the plugin to import and overwrite the inventory quantity file every 15 minutes and update the stock for the items imported in the inventory file.

Please Log in or Create an account to join the conversation.

  • Posts: 26000
  • Thank you received: 4004
  • MODERATOR
7 years 1 month ago #264294

Hi,

It is possible to do such thing thanks to a custom plugin.
But you should also be able to do it using a mass action.
www.hikashop.com/support/documentation/167-massaction-form.html

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

Please Log in or Create an account to join the conversation.

  • Posts: 128
  • Thank you received: 3
7 years 1 month ago #264406

Hey Jerome,
I've been looking at the mass action and creating a custom plugin documentation. I'm a little stuck as to how to proceed so I'm attaching an inventory file from my wholesaler so you can see more of what I need. The first thing I need to do is create a manufacturer category if it doesn't already exist and then assign that as the brand to the product. Based on different conditions of the csv file I need to assign the product to categories that are already created. For example:

  • if the csv line's caliber is not empty and the gun type is empty and the mag capacity is empty the product will need to be assigned to the ammunition category when created
  • if the csv line's caliber is not empty and the gun type is not empty and the mag capacity is not empty the product will need to be assigned to the firearms category when created
  • if the csv line's caliber is not empty and the gun type is empty and the mag capacity is not empty the product will need to be assigned to the magazines category when created
Would it be possible to do this with mass actions? If so how do I go about that? If not I did come across this thread https://www.hikashop.com/forum/4-how-to/3958-how-to-add-the-products-through-api.html and thought it may be helpful with a custom plugin. Would I need to parse through the csv file with a loop and storing those lines into an array so they can be manipulated to be able to do something like in this thread?

File Attachment:

File Name: inventory_all.csv
File Size:1,716 KB

Attachments:
Last edit: 7 years 1 month ago by deuce4884.

Please Log in or Create an account to join the conversation.

  • Posts: 81513
  • Thank you received: 13068
  • MODERATOR
7 years 1 month ago #264431

Hi,

If you need to have conditions dynamic during the import, then I'm afraid you'll have to write your own import system, or modify it on the fly in a script of yours before sending it to HikaShop's import system.
HikaShop actually already comes with an import plugin which can automatically import CSV files at a certain frequency:
www.hikashop.com/support/documentation/7...hop-import.html#cron
So you can copy that plugin to create your own and add your own custom processing to do the changes you need to before or after the import.

Please Log in or Create an account to join the conversation.

  • Posts: 128
  • Thank you received: 3
7 years 1 month ago #264758

Hey Nicolas,
Could you give me an example of how I could use a script to modify it on the fly using the conditions I mentioned above?

Please Log in or Create an account to join the conversation.

  • Posts: 81513
  • Thank you received: 13068
  • MODERATOR
7 years 1 month ago #264763

Hi,

If you're a developer then you should be able to do that yourself. For example, you could just run some MySQL queries on the products to update the data based on your needs after the import. You you could do some search and replace in the CSV content before the import. That's up to you.
I'm sorry but we can't spend half a day to code something for you as an example.

Please Log in or Create an account to join the conversation.

  • Posts: 128
  • Thank you received: 3
7 years 1 month ago #264786

Hey Nicolas,
I completely understand that you can't take that much time. I've decided I'm going to attempt to rewrite the csv file based on conditions I need prior to importing. Can you tell me if the datafeed plugin will allow me to specify what category and manufacturer to assign to the product being imported? If so how can I do this?

Please Log in or Create an account to join the conversation.

  • Posts: 81513
  • Thank you received: 13068
  • MODERATOR
7 years 1 month ago #264790

Hi,

You can add the category you want for the product in the "categories" column of the CSV. And for the manufacturer, it's the column product_manufacturer_id.

Please Log in or Create an account to join the conversation.

  • Posts: 128
  • Thank you received: 3
7 years 1 month ago #264902

For the "categories" column of the CSV file does it need to have a value of the appropriate category id or the appropriate category name? I'm assuming for the "product_manufacturer_id" column of the CSV file it has to be the appropriate manufacturer id? My CSV file currently has a "manufacturer" column where the manufacturer name is stored. Many of these manufacturers are not already created on my site. How can I assign a "product_manufacturer_id" to those that don't already exist?

Please Log in or Create an account to join the conversation.

  • Posts: 81513
  • Thank you received: 13068
  • MODERATOR
7 years 1 month ago #264959

Hi,

You can put either the category_id or the category_name. The system will automatically search for the id if you specify the name, and if the name is not found, it will automatically create the category.
And it's the same with the product_manufacturer_id column. You can put the id or the name in it.

Please Log in or Create an account to join the conversation.

  • Posts: 128
  • Thank you received: 3
7 years 3 weeks ago #266303

Hi,
I appreciate your help with everything. I've written a plugin that downloads the necessary file, rewrites the csv file, and then imports everything. It's working really well but I would like to be able to add tags to the products on import. Can this be done similarly to the way categories and manufacturers are done? If so, what's the column name that I enter in the plugin?

Please Log in or Create an account to join the conversation.

  • Posts: 81513
  • Thank you received: 13068
  • MODERATOR
7 years 3 weeks ago #266314

Hi,

If you're talking about the tags of the tags field in the product edition page, there is actually no system to either import or export them via the export/import of HikaShop.
That's because HikaShop actually doesn't store the information. As HikaShop integrates with Joomla for that feature, it's Joomla which stores the data and we don't have a lot of control over it. We can't easily insert/update the tags in batches like we do with the rest of the product data.

I would thus recommend to either not use the tags system but instead use a custom product field, or write your own code in your plugin to import the tags to the Joomla ucm, although that second option won't be easy.
forum.joomla.org/viewtopic.php?t=865582

Please Log in or Create an account to join the conversation.

  • Posts: 128
  • Thank you received: 3
5 years 11 months ago #292130

Hey,
I appreciate all your help with this process in the past and I have everything working great now for a while. I've got one new thing I'm trying to figure out now. My inventory file has changed now and has price breaks for different quantities purchased of a product. I have 2 different price groups dependent on the user. How can I write my csv file to provide these price breaks dependent on quantity? Do I use the "|" character somewhere? I'm already using this to separate the prices for the different user groups like ",5.00|10.00,"

Please Log in or Create an account to join the conversation.

  • Posts: 81513
  • Thank you received: 13068
  • MODERATOR
5 years 11 months ago #292148

Hi,

It's the same yes.
I would recommend to create one product with the prices exactly like you want, through the interface of the backend. Then, select that product on the listing of products and click the "export" button. That way, you'll get a CSV with your categories structure and only that product data. so you'll be able to check the different columns for the price: price_access, price_value and price_min_qty to see how it's done exactly for your case.

Please Log in or Create an account to join the conversation.

Time to create page: 0.084 seconds
Powered by Kunena Forum