使用管理产品页面中的自定义字段复选框-PrestaShop 1.6
我在产品管理页面中有一个自定义字段(复选框): 信息S.tpl:使用管理产品页面中的自定义字段复选框-PrestaShop 1.6,prestashop,prestashop-1.6,prestashop-1.7,prestashop-1.5,Prestashop,Prestashop 1.6,Prestashop 1.7,Prestashop 1.5,我在产品管理页面中有一个自定义字段(复选框): 信息S.tpl: <div class="form-group"> <div class="col-lg-1"> <span class="pull-right">{include file="controllers/products/multishop/checkbox.tpl" field="is_exclusive" type="checkbox" multilang="fa
<div class="form-group">
<div class="col-lg-1">
<span class="pull-right">{include file="controllers/products/multishop/checkbox.tpl" field="is_exclusive" type="checkbox" multilang="false"}</span></div>
<label class="control-label col-lg-2" for="is_exclusive">
<span class="label-tooltip" data-toggle="tooltip" title="{l s='Is Exclusive'}">
{l s='Is Exclusive ?'}
</span>
</label>
<div class="col-lg-9">
<input class="admin-form-check form-control" type="checkbox" id="is_exclusive" name="is_exclusive" value="1" {if $product->is_exclusive}checked{/if}/>
</div>
</div>
我需要一种方法来捕获复选框未选中的情况,并将字段指定为0
我已经创建了override/controllers/admin/AdminProductsController.php
:
public $is_exclusive = false;
function __construct( $id_product = null, $full = false, $id_lang = null, $id_shop = null, Context $context = null ) {
Product::$definition['fields']['is_exclusive'] =
array('type' => self::TYPE_BOOL, 'lang' => false, 'validate' => 'isBool');
class AdminProductsController extends AdminProductsControllerCore {
protected function copyFromPost(&$object, $table) {
if ( $this->isTabSubmitted( 'Informations' ) ) {
if ( $this->checkMultishopBox( 'is_exclusive', $this->context ) ) {
$object->is_exclusive = (int) Tools::getValue( 'is_exclusive' );
}
}
}
}
但这并不能解决问题。解决方案是删除缓存文件:
cache/class_index.php
在Prestashopp 1.6=>中是,解决方案是删除缓存文件:cache/class_index.php
在prestashop 1.7=>中,解决方案是删除缓存文件:var/cache/class_index.php
问候