Konrad B. Posted March 22 Share Posted March 22 Hi, i need to integrate some code for sales tracking purposes. It needs to be inserted in the body section. So i putted it into /themes/my-theme/templates/_partials/header.tpl at the top. It looks like in attachment (i was blocked while trying create topic with that code inserted as plain text or as code). My questions refer to the last section in the code dealing with category pages: 1. How can i get an array of products ID's from category pages (there's infinite scroll) in line: 'products' : '{/literal}['productId1','productId2','productId3']{literal}' 2. is there any simplier/better method to get 'categoryId' from category pages than: '{$smarty.get.id_category}'? Link to comment Share on other sites More sharing options...
ricardopxl Posted March 23 Share Posted March 23 I think the best option to do, is creating (adapting) one module and in the hook header add this. Link to comment Share on other sites More sharing options...
Konrad B. Posted March 25 Author Share Posted March 25 I was asking, how should look proper code in the line intead of ['productId1','productId2','productId3'], to get an array of products ID's from category pages. Link to comment Share on other sites More sharing options...
WisQQ Posted March 25 Share Posted March 25 Dnia 22.03.2024 o 10:50 AM, Konrad B. napisał: Hi, i need to integrate some code for sales tracking purposes. It needs to be inserted in the body section. So i putted it into /themes/my-theme/templates/_partials/header.tpl at the top. It looks like in attachment (i was blocked while trying create topic with that code inserted as plain text or as code). My questions refer to the last section in the code dealing with category pages: 1. How can i get an array of products ID's from category pages (there's infinite scroll) in line: 'products' : '{/literal}['productId1','productId2','productId3']{literal}' 2. is there any simplier/better method to get 'categoryId' from category pages than: '{$smarty.get.id_category}'? You will have to do it with module because category pages are using ProductListingController. Then you will be able to acess products by hooking into actionProductSearchAfter. After that you can return one single smarty variable. Here is part of this controller. $searchVariables = [ 'result' => $result, 'label' => $this->getListingLabel(), 'products' => $products, 'sort_orders' => $sort_orders, 'sort_selected' => $sort_selected, 'pagination' => $pagination, 'rendered_facets' => $rendered_facets, 'rendered_active_filters' => $rendered_active_filters, 'js_enabled' => $this->ajax, 'current_url' => $this->updateQueryString([ 'q' => $result->getEncodedFacets(), ]), ]; Hook::exec('filterProductSearch', ['searchVariables' => &$searchVariables]); Hook::exec('actionProductSearchAfter', $searchVariables); return $searchVariables; Link to comment Share on other sites More sharing options...
Konrad B. Posted March 27 Author Share Posted March 27 OK, thanks for your help 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