Jump to content

How idCombination works (hidden input in product.tpl) ?


missill

Recommended Posts

Hi all,

 

I'm new on prestashop and i'd like to understand how the idCombination on product.tpl is calculated ? Where is its script !?

 

I explain why i need to understand :

 

I have to perform an optical site with presta and i have to cut a lens product page in 2 parts for each eyes (left and right) with just one submit button.

 

And each lens product have its own declination attributes for the client's choice.

 

So, i need to get the correct value of idCombination for the second eye but i find nothing on this topic.

 

Thank you for helping me in advance.

 

Al.

Link to comment
Share on other sites

idCombination (alias id_product_attribute) is not "calculated". It is an unique identifier for each combination. 

 

Say you see dresses and you have them in two colors (red and blue) and two sizes (big and small). Now you have 4 possible combinations and each has its own combination of attributes (like red-small).

 

If you look in the database there are two tables involved. Ps_product_attribute gives a lot of properties (like price and weight) for each idCombination. Ps_product_attribute_combination connects that combination with the individual attributes. So it will have two entries: one about the color and one about the size. These entries at their turn will point to ps_attribute_* tables. 

 

id's in Prestashop are allocated according to the autoincrease principle and so are completely meaningless.

 

As for your lenses, I suggest that you make separate attributes for the left and the right lens. 

Link to comment
Share on other sites

Thanks a lot musicmaster for your explanations.

 

I understand better now but i still do not see how the value of idCombiantion is injected in its input field ? Where is the ajax or sql request script for this ?

 

As for your lenses, I suggest that you make separate attributes for the left and the right lens. "

 

I well separated attributes for each eyes, that's why i wanted to know how to get the idCombiantion because it generates itself for the left eye attributes and i have to generate myself for the right eye attributes.

Link to comment
Share on other sites

In a subdirectory of your theme you will find the file product.js. That is the Ajax file.

 

If you look in the source code of a product page you will find near the top something like:

	// Combinations attributes informations
	var attributesCombinations = new Array();
			tabInfos = new Array();
		tabInfos['id_attribute'] = '98';
		tabInfos['attribute'] = 'gezouten';
		tabInfos['group'] = 'zout';
		tabInfos['id_attribute_group'] = '16';
		attributesCombinations.push(tabInfos);
			tabInfos = new Array();
		tabInfos['id_attribute'] = '99';

This is from my site, so your values will be different, but it gives an impression what to expect.,

 

That is defined in product.tpl and provides the info for the combinations.

Link to comment
Share on other sites

Hello guys,

 

Thank you muscimaster and sorry for the late.

You have helped me a lot.

 

I have well modified the product.js (findCombination function), product.tpl & ajax-cart.js files overriden in my theme.

 

It works. Great !

 

Cheers all.

  • Like 1
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...