Jump to content

How can I get combinationId from array of id_attributes?


janusz.cebula

Recommended Posts

Hello all,

I use the Cart::updateQty() function in my module for prestashop. I'd like also to use the $id_product_attribute parameter, but I'm unable to find desired value for this, when I have array of id_attributes only. I need behaviour simillar to the default selecting product attributtes on the product page and then adding it to cart, but I'd like to do this on server side.

What I was able to find out is that when I'm changing a product attributes on the product page, the html input with id="idCombination" #idCombination is being filled with a proper value and then it's being POST'ed with ajax to the server. Unfortunately, I cannot work out how the actual searching is being made and how to do this in js or php code.

 

Quote

Long story short - I've got the $id_attributes [1, 2, 3, 4] and $product_id=10 and I need to find combinationId from those.

Any help would be appreciated.

2018-04-24_20h36_14.png

Edited by janusz.cebula (see edit history)
Link to comment
Share on other sites

What do you want to do  on your module ?

You are  trying to use a function is not on Prestashop (not 100% sure please if I am wrong let me know )

 

check it these out

on the product class you have

 

getProductAttributesIds  to got all the combinations

getAttributesParamas but these use the product_attribute_id

 

you can build an array them create your search

 

on the product controller the pass attributeCombinations to the template these is load on assigAttributesCombinations again if you check they use all the information

 

on the product.js they just create an array using the combinations as key example  1-2-3-4   when you choose one just rebuild the option to check wich one is the current

 

But always on the differents parts use a full array of information never use a function where they got only attributes ids

 

 

 

 

 

Link to comment
Share on other sites

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