Reputation: 149
I am trying to get available product combination (size) in product list page on each product. Basically there is a image, product name, available combinations, price, buy button.
I tried to out put $product object, but it does not have combination variable to it.
Is there any way to achieve that?
Upvotes: 0
Views: 2638
Reputation: 1016
There is function assignAttributesGroups()
in the ProductController.php
from where you can get code for size combination.
protected function assignAttributesGroups()
{
...
...
...
$this->context->smarty->assign(array(
'groups' => $groups,
'colors' => (count($colors)) ? $colors : false,
'combinations' => $combinations,
'combinationImages' => $combination_images
));
}
If you print the value of groups
you will get desired output. The combinations has been arranged to show dropdown in product.tpl
(/PRESTASHOP_FOLDER/themes/default-bootstrap/product.tpl) as shown in image
You can take a code from the function mentioned above and run it for every product in the list. You have to create a product object and receive combination through it. And create a drop down for the same.
Upvotes: 3