Cloud Nine Posted April 10, 2014 Share Posted April 10, 2014 (edited) Hello,I’ve made a module which list all products by category (for catgory 1, 2, 3, etc.). Users can choose products among different category without reloading pages.Its works but i need to list products with combinations.In my module, if i use getAttributeCombinations() in a loop , i get this result : Array ( [0] => Array ( [reference] => Array ( [0] => Array ( [id_product_attribute] => 165 [id_product] => 143 [reference] => XXXX-B6RG [supplier_reference] => [location] => [ean13] => [upc] => [wholesale_price] => 0.000000 [price] => 0.000000 [ecotax] => 0.000000 [quantity] => 43 [weight] => 0.000000 [unit_price_impact] => 0.00 [default_on] => 1 [minimal_quantity] => 1 [available_date] => 0000-00-00 [id_shop] => 1 [id_attribute_group] => 2 [is_color_group] => 1 [group_name] => Couleur [attribute_name] => Rouge [id_attribute] => 6 ) In smarty, i can do something like this but i'm not sure it's the right way to get all the results : {foreach from=$combinations[0] item=product name=test key=pro_key} <p>{$product.reference}</p> {/foreach} But, i need to get images of the product combinations. So, i've tried with getCombinationImages() in my module class : //inside a loop in array where there are all products in a category $combinations[$i] = $this_product->getCombinationImages($params['cookie']->id_lang); The result, if i make a print_r($combinations); The result : Array ( [0] => Array ( [165] => Array ( [0] => Array ( [id_image] => 58 [id_product_attribute] => 165 [legend] => ) ) [168] => Array ( [0] => Array ( [id_image] => 156 [id_product_attribute] => 168 [legend] => ) ) [166] => Array ( [0] => Array ( [id_image] => 157 [id_product_attribute] => 166 [legend] => ) ) [167] => Array ( [0] => Array ( [id_image] => 161 [id_product_attribute] => 167 [legend] => ) ) ) [1] => [2] => [3] => [4] => [5] => [6] => [7] => [8] => [9] => [10] => Array ( [173] => Array ( [0] => Array ( [id_image] => 71 [id_product_attribute] => 173 [legend] => ) ) [174] => Array ( [0] => Array ( [id_image] => 165 [id_product_attribute] => 174 [legend] => ) ) [175] => Array ( [0] => Array ( [id_image] => 166 [id_product_attribute] => 175 [legend] => ) ) [172] => Array ( [0] => Array ( [id_image] => 167 [id_product_attribute] => 172 [legend] => ) ) ) [11] => [12] => [13] => ) And i don't know how to handle it with smarty. It sounds too complex this kind of array. Do you think there is a bettter way to get all the images of all products conbination in a list ? thanks, best regards Edited April 11, 2014 by Cloud Nine (see edit history) Link to comment Share on other sites More sharing options...
hardyahir Posted April 24, 2017 Share Posted April 24, 2017 hey sorry for late reply but it might help others once you got id_image you can generate image url this way foreach ($combinations as $key => $val ) { $images[] = $link->getImageLink($product_array['link_rewrite'], [id_image] => 58 , 'large_default'); } /* this will generate array of URL for each id_image getImageLink() arguments are as explain below : first argument is 'link_rewrite' field from product_lang table for the given id_product, second argument is id_image so here as per above foreach its $val['id_image'], third argument is default image type you want to get from directory. usually large-default/medium-default used */ i hope this will solve you issue Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now