Prestashop 如何检查产品是否在愿望清单上
是否有人知道如何利用wishlist模块的任何功能在tpl中使用变量,以了解产品是否已添加到wishlist 如果我不存在,我设想可以使用一些函数,因为当你添加一个产品时,如果你已经在默认列表中,它会添加一个单位,而不是作为一个新产品添加 理想情况下,对于您需要的功能,它将不仅在默认情况下在列表中进行巡视,而且在所有情况下,有必要知道它是否已添加到列表中 功能是根据产品是否已在列表中显示图标 有人开发了吗?或者你能帮我吗 谢谢 Prestashop 1.6.1.16Prestashop 如何检查产品是否在愿望清单上,prestashop,Prestashop,是否有人知道如何利用wishlist模块的任何功能在tpl中使用变量,以了解产品是否已添加到wishlist 如果我不存在,我设想可以使用一些函数,因为当你添加一个产品时,如果你已经在默认列表中,它会添加一个单位,而不是作为一个新产品添加 理想情况下,对于您需要的功能,它将不仅在默认情况下在列表中进行巡视,而且在所有情况下,有必要知道它是否已添加到列表中 功能是根据产品是否已在列表中显示图标 有人开发了吗?或者你能帮我吗 谢谢 Prestashop 1.6.1.16 非常感谢你的贡献。 我给了
非常感谢你的贡献。 我给了我放在下面的代码,它总是给我一个“1”(如果你注意到,我发明了产品id(它不存在,因为我现在只有8个产品)。 我对模块的php进行了重写:
class BlockWishListOverride extends BlockWishList
{
function checkProductIsInWishlist()
{
$customer_wishlists = getByIdCustomer($this->context->customer->id);
$id_product_to_check = 424554224; // Replace by the current product id
foreach ($customer_wishlists as $cw) {
$check_product_wl = WishList::getProductByIdCustomer((int)$cw['id_wishlist'], (int)$this->context->customer->id,
(int)$this->context->language->id, (int)$id_product_to_check);
if (count($check_product_wl)) {
$this->smarty->assign('is_in_wishlist', true);
}
}
}
}
在my product.tpl中:
<p>Is in whislist: {$is_in_wishlist|print_r}</p>
在列表中:{$Is_in_wishlist | print_r}
正面结果:
谢谢您可以使用以下方法:
public static function getByIdCustomer($id_customer)
public static function getProductByIdCustomer($id_wishlist, $id_customer, $id_lang, $id_product = null, $quantity = false)
可在/modules/blockwishlist/WishList.php中找到
在控制器文件(前端)中,可以执行以下操作:
$customer_wishlists = WishList::getByIdCustomer($this->context->customer->id);
$id_product_to_check = 42; // Replace by the current product id
foreach ($customer_wishlists as $cw) {
$check_product_wl = WishList::getProductByIdCustomer((int)$cw['id_wishlist'], (int)$this->context->customer->id,
(int)$this->context->language->id, (int)$id_product_to_check);
if (count($check_product_wl)) {
$this->smarty->assign('is_in_wishlist', true);
}
}
然后检查Smarty product.tpl模板中的
{$is_in_wishlist}
变量。展示您的尝试-不要只期望有人为您做这些。@CFPSupport不仅“有人”回答了他的问题,而且还支持Bruno Leveque(PrestaShop创始人)did!!我无法解释我没有证明的东西,因为我不知道要使用什么函数。而且,我认为这是一个可以帮助社区完善wishlist模块的函数。感谢您给予Bruno的帮助。这是一个荣誉。@DSEO,请使用wishlist::getByIdCustomer()而不是getByIdCustomer()