Jump to content

[php class] Class for import / insert products directly into database


Kuba_

Recommended Posts

Hello,

 

Some days ago I've been looking for good method to import XML products into PrestaShop. I do found only modules with payment required, so I decided to write some small class to do this. XML reading code is not included, you have to do it on your own (eg. using SimpleXML built-in into php), but this class allows you to import products easily from any source like xml's, xls's or any format you want, because this simple code injects items directly into database.

 

This is the first version only with several methods, but in the future it probably will be developed forward.

 

Regards.

PrestaProduct.class.php

  • Like 5
Link to comment
Share on other sites

  • 2 weeks later...

This is exactly what i was looking for but the search module can not find the new product inserted any ideas why?

is it also possible to create new category if the category id is not found?

by the way thanks i really appreciated it.

Link to comment
Share on other sites

Hi Luis. I'm very happy that you found it cool.

Probably, product doesn't appear in the search module - because it needs to be inserted into one more table in database called ps_product_search or something similar. I'm not sure for this name but look for something like that. There are 'search indexes' and keywords for presta search engine so you need to add product to this table too. I forget to do this, but you can do it easily I think. Maybe in the future I'll write next version for this script to make it better.

Ad.2 At this moment it's not possible to create categories from this code. It's hardcoded to insert product to desired category described by ID. Maybe in the future I'll add this function to script v2.

Regards!

Link to comment
Share on other sites

  • 3 months later...
  • 3 weeks later...
  • 4 months later...
  • 1 month later...

Do you know what table should I add the products combination to? Is it ps_product_attribute_combination? Or is there any other table?

You have to create the attribute name, attribute value for get the code, after you have to create the product attribute and configure the combination

Link to comment
Share on other sites

  • 9 months later...

You have to create the attribute name, attribute value for get the code, after you have to create the product attribute and configure the combination

Hi criacaosites

 

I think i have to create attibutes in these tables
 
ps_attribute_group
ps_attribute_group_lang
ps_attribute_group_shop
ps_attribute
ps_attribute_lang
ps_attribute_shop
ps_attribute_impact
 
 
Then assign that attibute in this tables for combination
 
ps_product_attribute
ps_product_attribute_combination
ps_product_attribute_image
ps_product_attribute_shop
 
 
any enlightment in this regard would be a great help for me, Thank you
Link to comment
Share on other sites

 

Hi criacaosites

 

I think i have to create attibutes in these tables
 
ps_attribute_group
ps_attribute_group_lang
ps_attribute_group_shop
ps_attribute
ps_attribute_lang
ps_attribute_shop
ps_attribute_impact
 
 
Then assign that attibute in this tables for combination
 
ps_product_attribute
ps_product_attribute_combination
ps_product_attribute_image
ps_product_attribute_shop
 
 
any enlightment in this regard would be a great help for me, Thank you

 

Tank you, i for this tip.

i solved this problem some time ago.

i did finish my module bulk import amazon to prestashop and focalprice to prestashop with this class.

Link to comment
Share on other sites

Tank you, i for this tip.

i solved this problem some time ago.

i did finish my module bulk import amazon to prestashop and focalprice to prestashop with this class.

Hi

 

can you please share the attribute & combination creation part, rest i can handle, Thank you

Link to comment
Share on other sites

  • 5 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...