seog Posted April 2, 2017 Share Posted April 2, 2017 (edited) Hello I want add favorite products in product-list and i followed the next steps: In product-list.tpl just below of {if isset($product.on_sale) && $product.on_sale && <ul id="usefull_link_block" class="only-icon"> {if !$isCustomerFavoriteProduct} <li id="favoriteproducts_block_extra_add" rel="{$product.id_product}" class="add"></li> {/if} {if $isCustomerFavoriteProduct} <li id="favoriteproducts_block_extra_remove" rel="{$product.id_product}"></li> {/if} <li id="favoriteproducts_block_extra_added" rel="{$product.id_product}"></li> <li id="favoriteproducts_block_extra_removed" rel="{$product.id_product}"></li> </ul> In CategoryController.php in public function initContent() public function initContent() { parent::initContent(); $this->setTemplate(_PS_THEME_DIR_.'category.tpl'); if (!$this->customer_access) { return; } if (isset($this->context->cookie->id_compare)) { $this->context->smarty->assign('compareProducts', CompareProduct::getCompareProducts((int)$this->context->cookie->id_compare)); } if (Module::isEnabled('favoriteproducts')) { include_once(_PS_ROOT_DIR_ . '/modules/favoriteproducts/FavoriteProduct.php'); foreach ($this->cat_products as &$cat_product) { $cat_product['isCustomerFavoriteProduct'] = (FavoriteProduct::isCustomerFavoriteProduct($this->context->customer->id, $cat_product['id_product']) ? 1 : 0); } } // Product sort must be called before assignProductList() $this->productSort(); I obtain in product-list same code of product.tpl but if I click it then the .JS dont work, I think the problem is in the place where I added code to CategoryController.php Some suggestion? NOTE: I checked this and this options but it dont work PS 1.6.1.11 & FavoriteProducts V1.3.1 Edited April 2, 2017 by seog (see edit history) Link to comment Share on other sites More sharing options...
musicmaster Posted April 2, 2017 Share Posted April 2, 2017 I have no idea what you are doing. Is this on your homepage? Link to comment Share on other sites More sharing options...
seog Posted April 2, 2017 Author Share Posted April 2, 2017 (edited) I have no idea what you are doing. Is this on your homepage? Hello I said it: I want add favorite products in product-list and i followed the next steps: In product-list.tpl Product list and Category controller is for CATEGORIES best regards Edited April 2, 2017 by seog (see edit history) Link to comment Share on other sites More sharing options...
seog Posted April 4, 2017 Author Share Posted April 4, 2017 (edited) Hello I added in the right place the code in categorycontroller, within "public function assignProductList()": if (Module::isEnabled('favoriteproducts')) { include_once(_PS_ROOT_DIR_ . '/modules/favoriteproducts/FavoriteProduct.php'); foreach ($this->cat_products as &$cat_product) { $cat_product['isCustomerFavoriteProduct'] = (FavoriteProduct::isCustomerFavoriteProduct($this->context->customer->id, $cat_product['id_product']) ? 1 : 0); } } Now I have the issue that href link dont work because dont add product to favorites, it could be necessary to add a modified id="xxx" or other aditional rel="xxx" in product list: Original code of FavoriteProducts v1.3.1 added in product-list {if !$isCustomerFavoriteProduct AND $isLogged} <li id="favoriteproducts_block_extra_add" class="add"> {l s='Add this product to my list of favorites.' mod='favoriteproducts'} </li> {/if} {if $isCustomerFavoriteProduct AND $isLogged} <li id="favoriteproducts_block_extra_remove"> {l s='Remove this product from my favorite\'s list. ' mod='favoriteproducts'} </li> {/if} <li id="favoriteproducts_block_extra_added"> {l s='Remove this product from my favorite\'s list. ' mod='favoriteproducts'} </li> <li id="favoriteproducts_block_extra_removed"> {l s='Add this product to my list of favorites.' mod='favoriteproducts'} </li> I have been trying to change without success next code: <li id="favoriteproducts_block_extra_add" class="add"> for: <li id="favoriteproducts_block_extra_add" class="add" rel="ajax_id_favoriteproduct_{$favoriteProduct.id_product}"> Any suggestion for can add favorite product from categories calling from the id or rel to favoriteproduct.js functions ? Edited April 4, 2017 by seog (see edit history) 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