0

我有一个在 Prestashop 1.6 上运行的网站。我们能够安装和设置默认商店以及几个多商店。我们遇到的问题是,当我们继续为我们的位置创建多商店并将产品添加到这些商店时,我们希望这些产品显示在我们默认的“主”商店中。有没有办法做到这一点?

4

1 回答 1

0

我确信这种定制必须在代码中完成,但这并不难。您可以构建一个模块来查询产品并将其显示在任何显示挂钩中,例如displayLeftColumnProductdisplayHome

第二种方法是使用覆盖。覆盖Product类或ProductController可能也有效,但在这里我向您展示如何通过覆盖来做到这一点。

查看Product类,在getProducts方法(https://github.com/PrestaShop/PrestaShop/blob/1.6/classes/Product.php#L1069)中有一个调用来Shop::addSqlAssociation('product', 'p')为商店创建 JOIN。为了绕过它,我们需要重写Shop::addSqlAssociation方法(https://github.com/PrestaShop/PrestaShop/blob/1.6/classes/shop/Shop.php#L954)并检查当前商店是否是“大师”,例如:

class Shop extends ShopCore {

    public static function addSqlAssociation($table, $alias, $inner_join = true, $on = null, $force_not_default = false)
    {
        // It better to check using URL
        if (self::$context_id_shop == 1) return '';
        return parent::addSqlAssociation($table, $alias, $inner_join, $on, $force_not_default);
    }
}
于 2014-06-25T02:45:17.223 回答