Jump to content

Help making sql query for attributes


Salus

Recommended Posts

Hello everyone.

This may not be the right forum for this (let me know if its the case), but I desperately need some help in making an sql query and I dont know where else to go. I want a query made in myphpadmin, but I guess it would also work in prestashop.

 

I wish I can make a selective query from tables ps_product, ps_product_lang and not sure about the third table, I think it is ps_product_attribute, and export iti in csv.

 

I need to get every product quantity form products wich have attributes. I need fields like this: id_product from ps_product, reference from ps_product, product name from ps_product_lang, and here comes the part I dont know: all the attributes a product has. I  try make an example how the table should look:

 

Product ID    Ref ID Product Name (lang 2) Attribute Attribute2 Attribute 3              Quantity
1                   1001     Product name                   no attribute                                                 100
2                   1002     Product name 2                color-red size-32 model-zip                          3
2                   1002     Product name 2                color-red size-44 model-button                     4
2                   1002     Product name 2                color-blue size-36 model-zip                         5
3                   1003     Product name 3                blade type-curved no attribute no attribute   10

 

Problem is that attributes are always changing. Some products have only colors, some have color and size, some have shape and color, others again have no attributes. The important data I need here is quantities for each combination. After query is done, I need to modify quantity data and then UPLOAD back the data through phpmysql. 

 

Doing this manually is not an option since I have 1350 products, from wich 40-50% have multiple attributes.

 

Can this be done? Can anyone help me? Or point me towards a solution? I am stucked with this for a week now and cant advance further in releasing our site. I tried doing it myself but I do not speak proper sql  unfortunately, i dont know the proper commands and the syntax

 

Thanks is advance, any help is wellcome.

Edited by Salus (see edit history)
Link to comment
Share on other sites

:o Uh,oh, yes, i found it, this definitely looks like a good hint, please gimme some time to process and comprehend what am I just seeng here...

My php undestanding is also very low, specially concerning syntax, but I think I can grab something outta here.

Thanks, tuk66 :)

Edited by Salus (see edit history)
Link to comment
Share on other sites

  • 1 month later...

Maybe you managed it yourself by the time, but if not, please post your code.

 

In general, you need a product instance to call the function, calling it like Product::getAttributesResume won't work, because the function refers to $this->id_product. So you would have in call $product->new Product($id_product) first and afterwards $product->getAttributesResume($id_lang).

Link to comment
Share on other sites

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