2017-03-03 26 views
0

在Prestashop中添加新產品時,如果信息未完成,則必須小心禁用它。如何在Prestashop中默認禁用產品?

我試圖在ps_configuration表中找到一個關鍵字,但沒有任何關係,或者至少我找不到它。

現在的問題是如何在Prestashop中默認禁用產品?

回答

2

如果您使用的是v1.7,則在Shop Parameters - > Product Settings中有「Default activation status」選項。

如果您使用的是舊版本(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,因爲產品尚未保存。

相反,你可以改變/覆蓋管理模板文件/管理/主題/默認/模板/控制器/其中有源開關設置(約行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-> id。