Ronaldo Perez Posted January 4, 2012 Share Posted January 4, 2012 I feel like an idiot, send me in the right direction. - Added a new hook, - created in module method for this hook, - using the data (linked to the price of goods) Tools:: getValue ('id_product') - On the product page everything is OK, of course. I'm trying to use the same hook in product-list.tpl ie applied to each product on category page, but id_product not used here .. trying to think in the direction of Smarty (not clever - I know ), but templates are compiled after the php ... I cannot figure out how to get ID each item and pass it on "hook" in my head is spinning or JS or spit on it all and do this directly without using hooks I will be grateful for any of your thoughts:) Link to comment Share on other sites More sharing options...
bellini13 Posted January 4, 2012 Share Posted January 4, 2012 let's start by telling us what you are trying to accomplish within the product listing, are you trying to add some text within each product? Link to comment Share on other sites More sharing options...
Ronaldo Perez Posted January 4, 2012 Author Share Posted January 4, 2012 Oh, thanks for the quick response. No, add the same text, each product I can - it's not a problem. I need to add each item a "new price" is calculated based on the old price, for example - I want each item to show newPrice = oldPrice * 5 Link to comment Share on other sites More sharing options...
bellini13 Posted January 4, 2012 Share Posted January 4, 2012 why not just update the price in the catalog? if you make a change in the template, it is only going to effect the price shown in the template list. if a customer actually adds the product to the cart, the price will be the old price. if you want the product id within that template, the variable is {$product.id_product}. if you want the products price, the variable is {$product.price}. i would not recommend doing what you are doing, instead you should just update the products price in the back office catalog. if that is not an option for some reason, then I would suggest doing the calculation in the CategoryController, the following code in CategoryController sets the product array for use in the template. 'products' => (isset($this->cat_products) AND $this->cat_products) ? $this->cat_products : NULL, what i would suggest is to override the CategoryController, iterate through the $this->cat_products prior to adding it to the smarty array, and alter the product price accordingly. the template would not have to change then. again doing this will only effect the display on the product listing, it will have no bearing on the actual price of the item. Link to comment Share on other sites More sharing options...
Ronaldo Perez Posted January 4, 2012 Author Share Posted January 4, 2012 You probably do not understand me. 1. There is a module that calculates the price and other data using (based on) the product ID 2. The resulting data are displayed in a new hook - myHook 3. on the product page everything is OK, I get id_product - no problems 4. On category page - problem - I can not get id_product each product on category and pass out this id_product in "myHook" I can override CategoryController and get my desired result. But then I have to move all logic of module in the controller, and lost the whole point of using the module Link to comment Share on other sites More sharing options...
damonsk Posted January 6, 2012 Share Posted January 6, 2012 The product-list loops each product in the $products array. You would have to pass your hook the current product id as it executes the foreach. Not sure you can pass the current product as it loops from smarty. From http://www.prestasho...by_julien_breux As a guess, you would do something like below within your CategoryController method productListAssign. foreach($this->cat_products as &$cat_product) $productIDs[] = $cat_product['id_product']; Module::hookExec('NameOfHook', $productIDs); You would then have to loop through the array in your module to access the product id. Or I may be completely wrong. 1 Link to comment Share on other sites More sharing options...
Ronaldo Perez Posted January 6, 2012 Author Share Posted January 6, 2012 damonsizzle, do not even know how to thank you! You made me the right idea, I think ... I can do all the calculations for all the products on the page, and pass this array into a Smarty, then compare product ID and ID from array and display data in hook Thank you very much Link to comment Share on other sites More sharing options...
123santosh Posted June 7, 2012 Share Posted June 7, 2012 show product list 3 nos from each catagory show on the home page in prestashop module hot price module does not work 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