2017-03-03 6 views

답변

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를 반환하기 때문에 항상 작동하지 않습니다.

대신/변경에 대한 관리 템플릿 파일/관리/테마/기본/템플릿/컨트롤러/활성 스위치 (라인 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를 확인하십시오.