Jump to content

Get combination product from id's


JonasMersholm

Recommended Posts

Hi,

I'm trying to display quantity, combinations and etc. on the product-list. So far i've got it to display the combinations just fine, so that i can select an attribute from each group assigned to the product.

 

Now, how do i combine those "attribute id's" into a combination product, so that i can see prices, add it to cart etc.

 

 

This is my module to fetch combinations

	function hookdisplayProductOnList($params){
	    $product=new Product($params['id_product']);
        $combinations=$product->getAttributeCombinations($this->context->language->id);

        $combArray = [];
        $combArrayIds = [];

        foreach( $combinations as $k => $v )
        {	
        	if( !in_array($v["id_attribute"], $combArrayIds))
        	{
        		$combArrayIds[] = $v["id_attribute"];
        		$combArray[ $v["group_name"] ][] = $v;
        	}
        }

        $this->smarty->assign('combinations',$combArray);
        return $this->display(__FILE__, 'combinations.tpl');
	}

This is how i output the groups

{foreach $combinations as $k=>$comb}

	        <ul class="attribute-select" data-group="{$k}">
	        {foreach from=$comb item=attr}
	        	<li data-combId="{$attr.id_attribute}" title="{l s='+'} {convertPrice price=$attr.unit_price_impact}">{$attr.attribute_name}</li>
	        {/foreach}
	        </ul><br />


{/foreach}

Any help will be appreciated

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