如何在 Prestashop 中默认禁用产品?
How to disable products by default in Prestashop?
在 Prestashop 中添加新产品时,如果信息未完成,您必须小心禁用它。
我试图在ps_configuration
table中找到一个密钥,但是没有任何相关的东西,或者至少我找不到。
现在的问题是如何默认禁用 Prestashop 中的产品?
如果您使用的是 v1.7,在商店参数 -> 产品设置中有选项 "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 中,它会检查它是否与当前商店上下文相关联,并且它总是 return 错误,因为产品尚未保存。
相反,您可以 change/override 设置活动开关的管理模板文件 /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->id 的检查。
在 Prestashop 中添加新产品时,如果信息未完成,您必须小心禁用它。
我试图在ps_configuration
table中找到一个密钥,但是没有任何相关的东西,或者至少我找不到。
现在的问题是如何默认禁用 Prestashop 中的产品?
如果您使用的是 v1.7,在商店参数 -> 产品设置中有选项 "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 中,它会检查它是否与当前商店上下文相关联,并且它总是 return 错误,因为产品尚未保存。
相反,您可以 change/override 设置活动开关的管理模板文件 /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->id 的检查。