Reputation: 6868
When Adding new product in Prestashop, you have to be careful to disable it if it's information not completed.
I tried to find a key in ps_configuration
table, but there was nothing related to it, or at least I couldn't find it.
Now the question is how to disable product in Prestashop by default?
Upvotes: 0
Views: 819
Reputation: 2987
If you are using v1.7, there is the option "Default activation status" in Shop Parameters -> Product Settings.
If you are using an older version (1.6.x), try this override:
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;
}
When you add a new product the id_product is only set when saving.
EDIT: The above override doesn't always work because in the tpl, it checks if its associated to the current shop context, and it will always return false, because the product is not yet saved.
Instead, you can change/override the admin template file /admin/themes/default/template/controllers/products where the active switch is set (about line 196) change to:
<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>
Adding the check for the $product->id.
Upvotes: 2