Jump to content

How to add column in product


2mdee

Recommended Posts

Hello everybody,

AM newer on prestashop but i am a lil good in PHP.

I want to know how to add a column points of each product, i saw some tutorials in google but in some french forums of prestashop, they said that it's not the good solution.

If somebody can help.

Thanks.

Link to comment
Share on other sites

In PrestaShop 1.6 you can enable/disable the right/left column for whatever page (including product page) in the BO > Preferences > Themes > Click Advanced settings > And scroll bottom to the section "APPEARANCE OF COLUMNS"

 

I don't know if this solve your issue.

Link to comment
Share on other sites

Sorry COTOKO but i don't know if you understand what i want.

I need to add two columns in products entity, i will have also to add them in database, am looking for the better et safer way.

I saw what you already say, but i ask myself if that's the solution you gave me?

Regards,

Link to comment
Share on other sites

I don't know if you mean something like this:

 

1. Changes in DB:

alter table ps_product add column some_featurea tinyint(1) unsigned default 0;
alter table ps_product add column some_featureb tinyint(1) unsigned default 0;

 

2. Create file /override/classes/Product.php:

<?php
 class Product extends ProductCore {

   public $some_featurea;
   public $some_featureb

 

    public function __construct($id_product = null, $full = false, $id_lang = null, $id_shop = null, Context $context = null) {
         self::$definition['fields']['some_featurea'] = array('type' => self::TYPE_BOOL, 'validate' => 'isBool');
         self::$definition['fields']['some_featureb'] = array('type' => self::TYPE_BOOL, 'validate' => 'isBool');
         parent::__construct($id_product, $full, $id_lang, $id_shop, $context);
    }

}

 

3.  In admin template file /override/controllers/admin/templates/products/informations.tpl add following  code:

 

        <div class="form-group">
                <div class="col-lg-1"><span class="pull-right">{include file="controllers/products/multishop/checkbox.tpl" field="some_featurea" type="radio" onclick=""}</span></div>
                <label class="control-label col-lg-2">
                        {l s='some_featurea'}
                </label>
                <div class="col-lg-9">
                        <span class="switch prestashop-switch fixed-width-lg">
                                <input onclick="toggleDraftWarning(false);showOptions(true);" type="radio" name="some_featurea" id="some_featurea_on" value="1" {if $product->some_featurea || !$product->isAssociatedToShop()}checked="checked" {/if} />
                                <label for="some_featurea_on" class="radioCheck">
                                        {l s='Yes'}
                                </label>
                                <input onclick="toggleDraftWarning(true);showOptions(false);"  type="radio" name="some_featurea" id="some_featurea_off" value="0" {if !$product->some_featurea && $product->isAssociatedToShop()}checked="checked"{/if} />
                                <label for="some_featurea_off" class="radioCheck">
                                        {l s='No'}
                                </label>
                                <a class="slide-button btn"></a>
                        </span>
                </div>
        </div>
        <div class="form-group">
                <div class="col-lg-1"><span class="pull-right">{include file="controllers/products/multishop/checkbox.tpl" field="some_featureb" type="radio" onclick=""}</span></div>
                <label class="control-label col-lg-2">
                        {l s='some_featureb'}
                </label>
                <div class="col-lg-9">
                        <span class="switch prestashop-switch fixed-width-lg">
                                <input onclick="toggleDraftWarning(false);showOptions(true);" type="radio" name="some_featureb" id="some_featureb_on" value="1" {if $product->some_featureb || !$product->isAssociatedToShop()}checked="checked" {/if} />
                                <label for="some_featureb_on" class="radioCheck">
                                        {l s='Yes'}
                                </label>
                                <input onclick="toggleDraftWarning(true);showOptions(false);"  type="radio" name="some_featureb" id="some_featureb_off" value="0" {if !$product->some_featureb && $product->isAssociatedToShop()}checked="checked"{/if} />
                                <label for="some_featureb_off" class="radioCheck">
                                        {l s='No'}
                                </label>
                                <a class="slide-button btn"></a>
                        </span>
                </div>
        </div>

 

4. remove file /cache/class_index.php

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...