l33tas Posted October 4, 2013 Share Posted October 4, 2013 (edited) Hello, How to add image in history page. Its dont show for me.. I use this code: <img src="{$link->getImageLink($product.link_rewrite, $product.id_image, 'home_default')}" /> But now I know that product array hasnt link_rewrite and id_image... So I vardump product array: array(99) { ["id_order_detail"]=> string(2) "16" ["id_order"]=> string(1) "9" ["id_order_invoice"]=> string(1) "4" ["id_warehouse"]=> string(1) "0" ["id_shop"]=> string(1) "1" ["product_id"]=> string(1) "2" ["product_attribute_id"]=> string(1) "0" ["product_name"]=> string(41) "7715-1164A Elektrinė žvakidė -7 šakų" ["product_quantity"]=> string(1) "1" ["product_quantity_in_stock"]=> string(1) "1" ["product_quantity_refunded"]=> string(1) "0" ["product_quantity_return"]=> string(1) "0" ["product_quantity_reinjected"]=> string(1) "0" ["product_price"]=> string(9) "36.320000" ["reduction_percent"]=> string(4) "0.00" ["reduction_amount"]=> string(8) "0.000000" ["reduction_amount_tax_incl"]=> string(8) "0.000000" ["reduction_amount_tax_excl"]=> string(8) "0.000000" ["group_reduction"]=> string(4) "0.00" ["product_quantity_discount"]=> string(8) "0.000000" ["product_ean13"]=> string(0) "" ["product_upc"]=> string(0) "" ["product_reference"]=> string(0) "" ["product_supplier_reference"]=> string(0) "" ["product_weight"]=> string(8) "0.000000" ["tax_computation_method"]=> string(1) "0" ["tax_name"]=> string(0) "" ["tax_rate"]=> float(21) ["ecotax"]=> string(8) "0.000000" ["ecotax_tax_rate"]=> string(5) "0.000" ["discount_quantity_applied"]=> string(1) "0" ["download_hash"]=> string(0) "" ["download_nb"]=> string(1) "0" ["download_deadline"]=> string(19) "0000-00-00 00:00:00" ["total_price_tax_incl"]=> string(9) "43.950000" ["total_price_tax_excl"]=> string(9) "36.320000" ["unit_price_tax_incl"]=> string(9) "43.950000" ["unit_price_tax_excl"]=> string(9) "36.320000" ["total_shipping_price_tax_incl"]=> string(8) "0.000000" ["total_shipping_price_tax_excl"]=> string(8) "0.000000" ["purchase_supplier_price"]=> string(8) "0.000000" ["original_product_price"]=> string(9) "36.320000" ["id_product"]=> string(1) "2" ["id_supplier"]=> string(1) "0" ["id_manufacturer"]=> string(1) "0" ["id_category_default"]=> string(2) "18" ["id_shop_default"]=> string(1) "1" ["id_tax_rules_group"]=> string(1) "1" ["on_sale"]=> string(1) "0" ["online_only"]=> string(1) "0" ["ean13"]=> string(0) "" ["upc"]=> string(0) "" ["quantity"]=> string(1) "0" ["minimal_quantity"]=> string(1) "1" ["price"]=> string(9) "36.320000" ["wholesale_price"]=> string(8) "0.000000" ["unity"]=> string(0) "" ["unit_price_ratio"]=> string(8) "0.000000" ["additional_shipping_cost"]=> string(4) "0.00" ["reference"]=> string(0) "" ["supplier_reference"]=> string(0) "" ["location"]=> string(0) "" ["width"]=> string(8) "0.000000" ["height"]=> string(8) "0.000000" ["depth"]=> string(8) "0.000000" ["weight"]=> string(8) "0.000000" ["out_of_stock"]=> string(1) "2" ["quantity_discount"]=> string(1) "0" ["customizable"]=> string(1) "0" ["uploadable_files"]=> string(1) "0" ["text_fields"]=> string(1) "0" ["active"]=> string(1) "1" ["redirect_type"]=> string(3) "404" ["id_product_redirected"]=> string(1) "0" ["available_for_order"]=> string(1) "1" ["available_date"]=> string(10) "0000-00-00" ["condition"]=> string(3) "new" ["show_price"]=> string(1) "1" ["indexed"]=> string(1) "1" ["visibility"]=> string(4) "both" ["cache_is_pack"]=> string(1) "0" ["cache_has_attachments"]=> string(1) "0" ["is_virtual"]=> string(1) "0" ["cache_default_attribute"]=> string(1) "0" ["date_add"]=> string(19) "2013-09-25 10:56:36" ["date_upd"]=> string(19) "2013-09-26 14:13:49" ["advanced_stock_management"]=> string(1) "0" ["image"]=> object(Image)#270 (26) { ["id"]=> int(4) ["id_image"]=> string(1) "4" ["id_product"]=> string(1) "2" ["position"]=> string(1) "1" ["cover"]=> string(1) "1" ["image_format"]=> string(3) "jpg" ["source_index"]=> string(53) "/home/lt.svelitus.www/svelitus/htdocs/img/p/index.php" ["folder":protected]=> NULL ["existing_path":protected]=> NULL ["id_lang":protected]=> NULL ["id_shop":protected]=> int(1) ["id_shop_list"]=> NULL ["get_shop_from_context":protected]=> bool(true) ["table":protected]=> string(5) "image" ["identifier":protected]=> string(8) "id_image" ["fieldsRequired":protected]=> array(1) { [0]=> string(10) "id_product" } ["fieldsSize":protected]=> array(0) { } ["fieldsValidate":protected]=> array(3) { ["id_product"]=> string(12) "isUnsignedId" ["position"]=> string(13) "isUnsignedInt" ["cover"]=> string(6) "isBool" } ["fieldsRequiredLang":protected]=> array(0) { } ["fieldsSizeLang":protected]=> array(0) { } ["fieldsValidateLang":protected]=> array(0) { } ["tables":protected]=> array(0) { } ["webserviceParameters":protected]=> array(0) { } ["image_dir":protected]=> string(44) "/home/lt.svelitus.www/svelitus/htdocs/img/p/" ["def":protected]=> array(6) { ["table"]=> string(5) "image" ["primary"]=> string(8) "id_image" ["multilang"]=> bool(true) ["fields"]=> array(3) { ["id_product"]=> array(3) { ["type"]=> int(1) ["validate"]=> string(12) "isUnsignedId" ["required"]=> bool(true) } ["position"]=> array(2) { ["type"]=> int(1) ["validate"]=> string(13) "isUnsignedInt" } ["cover"]=> array(3) { ["type"]=> int(2) ["validate"]=> string(6) "isBool" ["shop"]=> bool(true) } } ["classname"]=> string(5) "Image" ["associations"]=> array(1) { ["l"]=> array(3) { ["type"]=> int(2) ["field"]=> string(8) "id_image" ["foreign_field"]=> string(8) "id_image" } } } ["update_fields":protected]=> NULL } ["image_size"]=> NULL ["current_stock"]=> int(199) ["tax_calculator"]=> object(TaxCalculator)#272 (2) { ["taxes"]=> array(1) { [0]=> object(Tax)#271 (23) { ["name"]=> array(2) { [1]=> string(10) "PVM LT 21%" [2]=> string(10) "PVM LT 21%" } ["rate"]=> string(6) "21.000" ["active"]=> string(1) "1" ["deleted"]=> string(1) "0" ["webserviceParameters":protected]=> array(1) { ["objectsNodeName"]=> string(5) "taxes" } ["id"]=> int(1) ["id_lang":protected]=> NULL ["id_shop":protected]=> NULL ["id_shop_list"]=> NULL ["get_shop_from_context":protected]=> bool(true) ["table":protected]=> string(3) "tax" ["identifier":protected]=> string(6) "id_tax" ["fieldsRequired":protected]=> array(1) { [0]=> string(4) "rate" } ["fieldsSize":protected]=> array(0) { } ["fieldsValidate":protected]=> array(1) { ["rate"]=> string(7) "isFloat" } ["fieldsRequiredLang":protected]=> array(1) { [0]=> string(4) "name" } ["fieldsSizeLang":protected]=> array(1) { ["name"]=> int(32) } ["fieldsValidateLang":protected]=> array(1) { ["name"]=> string(13) "isGenericName" } ["tables":protected]=> array(0) { } ["image_dir":protected]=> NULL ["image_format":protected]=> string(3) "jpg" ["def":protected]=> array(6) { ["table"]=> string(3) "tax" ["primary"]=> string(6) "id_tax" ["multilang"]=> bool(true) ["fields"]=> array(4) { ["rate"]=> array(3) { ["type"]=> int(4) ["validate"]=> string(7) "isFloat" ["required"]=> bool(true) } ["active"]=> array(1) { ["type"]=> int(2) } ["deleted"]=> array(1) { ["type"]=> int(2) } ["name"]=> array(5) { ["type"]=> int(3) ["lang"]=> bool(true) ["validate"]=> string(13) "isGenericName" ["required"]=> bool(true) ["size"]=> int(32) } } ["classname"]=> string(3) "Tax" ["associations"]=> array(1) { ["l"]=> array(3) { ["type"]=> int(2) ["field"]=> string(6) "id_tax" ["foreign_field"]=> string(6) "id_tax" } } } ["update_fields":protected]=> NULL } } ["computation_method"]=> int(0) } ["product_price_wt"]=> string(9) "43.950000" ["product_price_wt_but_ecotax"]=> float(43.95) ["total_wt"]=> string(9) "43.950000" ["total_price"]=> string(9) "36.320000" ["customizedDatas"]=> NULL ["customizationQuantityTotal"]=> int(0) ["id_address_delivery"]=> string(1) "7" ["qty_returned"]=> string(1) "0" } Any have this problem and solved?? Edited October 15, 2013 by l33tas (see edit history) Link to comment Share on other sites More sharing options...
pzi Posted October 4, 2013 Share Posted October 4, 2013 Hi, Nice idea, that I didn't have but that I will copy and use on my site. In order to make appear the product image you can use something like: <img src="{$link->getImageLink('productimage', $product.image->id_image, 'home_default')}" /> The ID of the image is stored in an Image object inside the $product variable. You are right, the 'link_rewrite' info is not available here, but there just needs to have something in it: it could be anything else than 'productimage'. Any one an idea to get the link rewrite info? And if you want to change size of image try small_default or medium_default instead of home_default. I added this code in order-detail.tpl file, just before the name of the product (for classic products) I tried this on my 1.5.4.1, and it works nicely. 4 Link to comment Share on other sites More sharing options...
l33tas Posted October 15, 2013 Author Share Posted October 15, 2013 solved. thx pzi Link to comment Share on other sites More sharing options...
pzi Posted October 15, 2013 Share Posted October 15, 2013 Glad it could help. Best regards Link to comment Share on other sites More sharing options...
sanookjung Posted December 10, 2013 Share Posted December 10, 2013 array(99) { ["id_order_detail"]=> string(2) "16" ["id_order"]=> string(1) "9" ["id_order_invoice"]=> string(1) "4" ["id_warehouse"]=> string(1) "0" ["id_shop"]=> string(1) "1" ["product_id"]=> string(1) "2" ["product_attribute_id"]=> string(1) "0" ["product_name"]=> string(41) "7715-1164A Elektrinė žvakidė -7 šakų" ["product_quantity"]=> string(1) "1" ["product_quantity_in_stock"]=> string(1) "1" ["product_quantity_refunded"]=> string(1) "0" ["product_quantity_return"]=> string(1) "0" ["product_quantity_reinjected"]=> string(1) "0" ["product_price"]=> string(9) "36.320000" ["reduction_percent"]=> string(4) "0.00" ["reduction_amount"]=> string(8) "0.000000" ["reduction_amount_tax_incl"]=> string(8) "0.000000" ["reduction_amount_tax_excl"]=> string(8) "0.000000" ["group_reduction"]=> string(4) "0.00" ["product_quantity_discount"]=> string(8) "0.000000" ["product_ean13"]=> string(0) "" ["product_upc"]=> string(0) "" ["product_reference"]=> string(0) "" ["product_supplier_reference"]=> string(0) "" ["product_weight"]=> string(8) "0.000000" ["tax_computation_method"]=> string(1) "0" ["tax_name"]=> string(0) "" ["tax_rate"]=> float(21) ["ecotax"]=> string(8) "0.000000" ["ecotax_tax_rate"]=> string(5) "0.000" ["discount_quantity_applied"]=> string(1) "0" ["download_hash"]=> string(0) "" ["download_nb"]=> string(1) "0" ["download_deadline"]=> string(19) "0000-00-00 00:00:00" ["total_price_tax_incl"]=> string(9) "43.950000" ["total_price_tax_excl"]=> string(9) "36.320000" ["unit_price_tax_incl"]=> string(9) "43.950000" ["unit_price_tax_excl"]=> string(9) "36.320000" ["total_shipping_price_tax_incl"]=> string(8) "0.000000" ["total_shipping_price_tax_excl"]=> string(8) "0.000000" ["purchase_supplier_price"]=> string(8) "0.000000" ["original_product_price"]=> string(9) "36.320000" ["id_product"]=> string(1) "2" ["id_supplier"]=> string(1) "0" ["id_manufacturer"]=> string(1) "0" ["id_category_default"]=> string(2) "18" ["id_shop_default"]=> string(1) "1" ["id_tax_rules_group"]=> string(1) "1" ["on_sale"]=> string(1) "0" ["online_only"]=> string(1) "0" ["ean13"]=> string(0) "" ["upc"]=> string(0) "" ["quantity"]=> string(1) "0" ["minimal_quantity"]=> string(1) "1" ["price"]=> string(9) "36.320000" ["wholesale_price"]=> string(8) "0.000000" ["unity"]=> string(0) "" ["unit_price_ratio"]=> string(8) "0.000000" ["additional_shipping_cost"]=> string(4) "0.00" ["reference"]=> string(0) "" ["supplier_reference"]=> string(0) "" ["location"]=> string(0) "" ["width"]=> string(8) "0.000000" ["height"]=> string(8) "0.000000" ["depth"]=> string(8) "0.000000" ["weight"]=> string(8) "0.000000" ["out_of_stock"]=> string(1) "2" ["quantity_discount"]=> string(1) "0" ["customizable"]=> string(1) "0" ["uploadable_files"]=> string(1) "0" ["text_fields"]=> string(1) "0" ["active"]=> string(1) "1" ["redirect_type"]=> string(3) "404" ["id_product_redirected"]=> string(1) "0" ["available_for_order"]=> string(1) "1" ["available_date"]=> string(10) "0000-00-00" ["condition"]=> string(3) "new" ["show_price"]=> string(1) "1" ["indexed"]=> string(1) "1" ["visibility"]=> string(4) "both" ["cache_is_pack"]=> string(1) "0" ["cache_has_attachments"]=> string(1) "0" ["is_virtual"]=> string(1) "0" ["cache_default_attribute"]=> string(1) "0" ["date_add"]=> string(19) "2013-09-25 10:56:36" ["date_upd"]=> string(19) "2013-09-26 14:13:49" ["advanced_stock_management"]=> string(1) "0" ["image"]=> object(Image)#270 (26) { ["id"]=> int(4) ["id_image"]=> string(1) "4" ["id_product"]=> string(1) "2" ["position"]=> string(1) "1" ["cover"]=> string(1) "1" ["image_format"]=> string(3) "jpg" ["source_index"]=> string(53) "/home/lt.svelitus.www/svelitus/htdocs/img/p/index.php" ["folder":protected]=> NULL ["existing_path":protected]=> NULL ["id_lang":protected]=> NULL ["id_shop":protected]=> int(1) ["id_shop_list"]=> NULL ["get_shop_from_context":protected]=> bool(true) ["table":protected]=> string(5) "image" ["identifier":protected]=> string(8) "id_image" ["fieldsRequired":protected]=> array(1) { [0]=> string(10) "id_product" } ["fieldsSize":protected]=> array(0) { } ["fieldsValidate":protected]=> array(3) { ["id_product"]=> string(12) "isUnsignedId" ["position"]=> string(13) "isUnsignedInt" ["cover"]=> string(6) "isBool" } ["fieldsRequiredLang":protected]=> array(0) { } ["fieldsSizeLang":protected]=> array(0) { } ["fieldsValidateLang":protected]=> array(0) { } ["tables":protected]=> array(0) { } ["webserviceParameters":protected]=> array(0) { } ["image_dir":protected]=> string(44) "/home/lt.svelitus.www/svelitus/htdocs/img/p/" ["def":protected]=> array(6) { ["table"]=> string(5) "image" ["primary"]=> string(8) "id_image" ["multilang"]=> bool(true) ["fields"]=> array(3) { ["id_product"]=> array(3) { ["type"]=> int(1) ["validate"]=> string(12) "isUnsignedId" ["required"]=> bool(true) } ["position"]=> array(2) { ["type"]=> int(1) ["validate"]=> string(13) "isUnsignedInt" } ["cover"]=> array(3) { ["type"]=> int(2) ["validate"]=> string(6) "isBool" ["shop"]=> bool(true) } } ["classname"]=> string(5) "Image" ["associations"]=> array(1) { ["l"]=> array(3) { ["type"]=> int(2) ["field"]=> string(8) "id_image" ["foreign_field"]=> string(8) "id_image" } } } ["update_fields":protected]=> NULL } ["image_size"]=> NULL ["current_stock"]=> int(199) ["tax_calculator"]=> object(TaxCalculator)#272 (2) { ["taxes"]=> array(1) { [0]=> object(Tax)#271 (23) { ["name"]=> array(2) { [1]=> string(10) "PVM LT 21%" [2]=> string(10) "PVM LT 21%" } ["rate"]=> string(6) "21.000" ["active"]=> string(1) "1" ["deleted"]=> string(1) "0" ["webserviceParameters":protected]=> array(1) { ["objectsNodeName"]=> string(5) "taxes" } ["id"]=> int(1) ["id_lang":protected]=> NULL ["id_shop":protected]=> NULL ["id_shop_list"]=> NULL ["get_shop_from_context":protected]=> bool(true) ["table":protected]=> string(3) "tax" ["identifier":protected]=> string(6) "id_tax" ["fieldsRequired":protected]=> array(1) { [0]=> string(4) "rate" } ["fieldsSize":protected]=> array(0) { } ["fieldsValidate":protected]=> array(1) { ["rate"]=> string(7) "isFloat" } ["fieldsRequiredLang":protected]=> array(1) { [0]=> string(4) "name" } ["fieldsSizeLang":protected]=> array(1) { ["name"]=> int(32) } ["fieldsValidateLang":protected]=> array(1) { ["name"]=> string(13) "isGenericName" } ["tables":protected]=> array(0) { } ["image_dir":protected]=> NULL ["image_format":protected]=> string(3) "jpg" ["def":protected]=> array(6) { ["table"]=> string(3) "tax" ["primary"]=> string(6) "id_tax" ["multilang"]=> bool(true) ["fields"]=> array(4) { ["rate"]=> array(3) { ["type"]=> int(4) ["validate"]=> string(7) "isFloat" ["required"]=> bool(true) } ["active"]=> array(1) { ["type"]=> int(2) } ["deleted"]=> array(1) { ["type"]=> int(2) } ["name"]=> array(5) { ["type"]=> int(3) ["lang"]=> bool(true) ["validate"]=> string(13) "isGenericName" ["required"]=> bool(true) ["size"]=> int(32) } } ["classname"]=> string(3) "Tax" ["associations"]=> array(1) { ["l"]=> array(3) { ["type"]=> int(2) ["field"]=> string(6) "id_tax" ["foreign_field"]=> string(6) "id_tax" } } } ["update_fields":protected]=> NULL } } ["computation_method"]=> int(0) } ["product_price_wt"]=> string(9) "43.950000" ["product_price_wt_but_ecotax"]=> float(43.95) ["total_wt"]=> string(9) "43.950000" ["total_price"]=> string(9) "36.320000" ["customizedDatas"]=> NULL ["customizationQuantityTotal"]=> int(0) ["id_address_delivery"]=> string(1) "7" ["qty_returned"]=> string(1) "0" } Where is file ? Link to comment Share on other sites More sharing options...
ps_742 Posted December 15, 2015 Share Posted December 15, 2015 Put following piece of code under front/controllers/OrderDetailsController.php/*************************************************/just After following peice of code$this->context->smarty->assign(array( /*************************************************/ foreach($products as $k=>$v) { $id_product = $v['id_product']; $image = Image::getCover($id_product); $product = new Product($id_product, false, Context::getContext()->language->id); $link = new Link; //because getImageLInk is not static function $imagePath = $link->getImageLink($product->link_rewrite, $image['id_image'], 'small_default'); $path = explode('/',$imagePath) ; $path_i =array_reverse($path); $p_img[$id_product]= $path_i[1].'/'.$path_i[0]; }Then put 'p_img' => $p_img, at smarty i.e $this->context->smarty->assign(array( 'shop_name' => strval(Configuration::get('PS_SHOP_NAME')), 'order' => $order, 'p_img' => $p_img, 'return_allowed' => (int)$order->isReturnable(), 'currency' => new Currency($order->id_currency), 'order_state' => (int)$id_order_state, 'invoiceAllowed' => (int)(Configuration::get('PS_INVOICE')), 'invoice' => (OrderState::invoiceAvailable($id_order_state) && count($order->getInvoicesCollection())), 'order_history' => $order->getHistory($this->context->language->id, false, true), 'products' => $products, 'discounts' => $order->getCartRules(), 'carrier' => $carrier, 'address_invoice' => $addressInvoice, 'invoiceState' => (Validate::isLoadedObject($addressInvoice) && $addressInvoice->id_state) ? new State($addressInvoice->id_state) : false, 'address_delivery' => $addressDelivery, 'inv_adr_fields' => $inv_adr_fields, 'dlv_adr_fields' => $dlv_adr_fields, 'invoiceAddressFormatedValues' => $invoiceAddressFormatedValues, 'deliveryAddressFormatedValues' => $deliveryAddressFormatedValues, 'deliveryState' => (Validate::isLoadedObject($addressDelivery) && $addressDelivery->id_state) ? new State($addressDelivery->id_state) : false, 'is_guest' => false, 'messages' => CustomerMessage::getMessagesByOrderId((int)($order->id), false), 'CUSTOMIZE_FILE' => Product::CUSTOMIZE_FILE, 'CUSTOMIZE_TEXTFIELD' => Product::CUSTOMIZE_TEXTFIELD, 'isRecyclable' => Configuration::get('PS_RECYCLABLE_PACK'), 'use_tax' => Configuration::get('PS_TAX'), 'group_use_tax' => (Group::getPriceDisplayMethod($customer->id_default_group) == PS_TAX_INC), /* DEPRECATED: customizedDatas @since 1.5 */ 'customizedDatas' => $customizedDatas, /* DEPRECATED: customizedDatas @since 1.5 */ 'reorderingAllowed' => !(int)(Configuration::get('PS_DISALLOW_HISTORY_REORDERING')) ));then use that variable at order-detail.tpl after 293 LOC (<!-- Classic products -->)<td><!--{$product|@print_r}--><img src="{$p_img.$productId}" /></td> let me know if you have any query Link to comment Share on other sites More sharing options...
Recommended Posts