如何在Prestashop中默认禁用产品?

时间:2017-03-03 09:47:47

标签: prestashop product

在Prestashop中添加新产品时,如果信息未完成,则必须小心禁用它。

我试图在ps_configuration表中找到一个键,但没有任何相关内容,或者至少我找不到它。

现在问题是如何在默认情况下禁用Prestashop中的产品?

1 个答案:

答案 0 :(得分:2)

如果您使用的是v1.7,则商店参数中有“默认激活状态”选项 - >产品设置。

如果您使用的是旧版本(1.6.x),请尝试以下覆盖:

public function __construct($id_product = null, $full = false, $id_lang = null, $id_shop = null, Context $context = null)
{
    parent::__construct($id_product, $full, $id_lang, $id_shop, $context);
    if($id_product == null)
        $this->active = false;
}

添加新产品时,仅在保存时设置id_product。

编辑:上面的覆盖并不总是有效,因为在tpl中,它会检查它是否与当前的商店上下文相关联,并且它将始终返回false,因为产品尚未保存。

相反,您可以更改/覆盖管理模板文件/ admin / themes / default / template / controllers / products,其中设置了活动开关(关于第196行)更改为:

<span class="switch prestashop-switch fixed-width-lg">
    <input onclick="toggleDraftWarning(false);showOptions(true);showRedirectProductOptions(false);" type="radio" name="active" id="active_on" value="1" {if $product->id != null && ( $product->active || !$product->isAssociatedToShop())}checked="checked" {/if} />
    <label for="active_on" class="radioCheck">
        {l s='Yes'}
    </label>
    <input onclick="toggleDraftWarning(true);showOptions(false);showRedirectProductOptions(true);"  type="radio" name="active" id="active_off" value="0" {if $product->id == null || (!$product->active && $product->isAssociatedToShop())}checked="checked"{/if} />
    <label for="active_off" class="radioCheck">
        {l s='No'}
    </label>
    <a class="slide-button btn"></a>
</span>

添加$ product-&gt; id。

的支票
相关问题