neoh Posted March 13, 2014 Share Posted March 13, 2014 Hi, Out of box, PrestaShop allows me to add product short and long description very easily. Apart from description I also need to sometimes add product features, package contents and technical specification of the given product. In the screenshot below I showed how I would like the module to work from back end. I searched google but I couldn't find good solution. I found module called "Project page content blocks" which technically would work but is very impractical in my case. Thanks for help. Link to comment Share on other sites More sharing options...
vekia Posted March 13, 2014 Share Posted March 13, 2014 there is no module like that, it's because to achieve this you have to modify controllers and admin + front office templates related to product & product edit page. if you're still interested in this, you will have to define new fields in database (alter table ps_product_lang). Then you have to extend product ObjectModel definition (add these new fields to Product.php class)And last step Modify admin controller to display this field, and template to display textbox with tinymce editor to enter own data. Link to comment Share on other sites More sharing options...
neoh Posted March 13, 2014 Author Share Posted March 13, 2014 if you're still interested in this, you will have to define new fields in database (alter table ps_product_lang). Then you have to extend product ObjectModel definition (add these new fields to Product.php class) And last step Modify admin controller to display this field, and template to display textbox with tinymce editor to enter own data. After I update PrestaShop, all changes would be lost, is that right? Link to comment Share on other sites More sharing options...
vekia Posted March 13, 2014 Share Posted March 13, 2014 if you will use overrides - not, you will not lose these changes. Link to comment Share on other sites More sharing options...
neoh Posted March 14, 2014 Author Share Posted March 14, 2014 I defined new fields in table - easy bit. For the "Product.php class" I believe you are referring to the "classes/product.php" file and the "admin controller" would be "controllers/admin/AdminProductsController.php"? Thanks for help. Link to comment Share on other sites More sharing options...
vekia Posted March 15, 2014 Share Posted March 15, 2014 yes, that's correct class: classes/product.php controller: controllers/admin/AdminProductsController.php 1 Link to comment Share on other sites More sharing options...
neoh Posted March 16, 2014 Author Share Posted March 16, 2014 I actually only edited file below and everything works: classes/product.php admin111/themes/default/template/controllers/products/informations.tpl themes/default/product.tpl Would you mind telling more about what exactly I had to edit in AdminProductsController.php Link to comment Share on other sites More sharing options...
vekia Posted March 17, 2014 Share Posted March 17, 2014 before i will start, may i know what you already did? Link to comment Share on other sites More sharing options...
neoh Posted March 17, 2014 Author Share Posted March 17, 2014 (edited) 1. Added new columns to the table. Columns named product_features, box_contents and product_technical_specs. 2. classes/product.php - declared global variables /** @var string Product features*/ public $product_features; /** @var string Box contents*/ public $box_contents; /** @var string Product technical specs*/ public $product_technical_specs; - edited Lang fields in the $definition array /* Lang fields */ 'meta_description' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 255), 'meta_keywords' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 255), 'meta_title' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 128), 'link_rewrite' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isLinkRewrite', 'required' => true, 'size' => 128), 'name' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isCatalogName', 'required' => true, 'size' => 128), 'description' => array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isCleanHtml'), 'description_short' => array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isCleanHtml'), 'product_features' => array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isCleanHtml'), 'box_contents' => array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isCleanHtml'), 'product_technical_specs' => array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isCleanHtml'), 'available_now' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 255), 'available_later' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'IsGenericName', 'size' => 255), 3. admin111/themes/default/template/controllers/products/informations.tpl - added three more rows to the table and coded that displays text editor in admin <tr><!-- Added by Matthew - Product features --> <td class="col-left"> {include file="controllers/products/multishop/checkbox.tpl" field="product_features" type="tinymce" multilang="true"} <label>{l s='Product features:'}<br /></label> <p class="product_description">({l s='Appears in the body of the product page'})</p> </td> <td style="padding-bottom:5px;"> {include file="controllers/products/textarea_lang.tpl" languages=$languages input_name='product_features' input_value=$product->product_features } <p class="clear"></p> </td> </tr> <tr> <!-- Added by Matthew - Box contents --> <td class="col-left"> {include file="controllers/products/multishop/checkbox.tpl" field="box_contents" type="tinymce" multilang="true"} <label>{l s='Box contents:'}<br /></label> <p class="product_description">({l s='Appears in the body of the product page'})</p> </td> <td style="padding-bottom:5px;"> {include file="controllers/products/textarea_lang.tpl" languages=$languages input_name='box_contents' input_value=$product->box_contents } <p class="clear"></p> </td> </tr> <tr> <!-- Added by Matthew - Product technical specs --> <td class="col-left"> {include file="controllers/products/multishop/checkbox.tpl" field="product_technical_specs" type="tinymce" multilang="true"} <label>{l s='Product technical specs:'}<br /></label> <p class="product_description">({l s='Appears in the body of the product page'})</p> </td> <td style="padding-bottom:5px;"> {include file="controllers/products/textarea_lang.tpl" languages=$languages input_name='product_technical_specs' input_value=$product->product_technical_specs } <p class="clear"></p> </td> /tr> 4. themes/default/product.tpl - added code to the template to display data {if isset($product) && $product->product_features}<h2 class="product_header">Product features</h2>{$product->product_features}{/if} {if isset($product) && $product->box_contents}<h2 class="product_header">Contents</h2>{$product->box_contents}{/if} {if isset($product) && $product->product_technical_specs}<h2 class="product_header">Technical specification</h2>{$product->product_technical_specs}{/if} Edited March 17, 2014 by neoh (see edit history) Link to comment Share on other sites More sharing options...
neoh Posted March 24, 2014 Author Share Posted March 24, 2014 @vekia, would you mind explaining that? Link to comment Share on other sites More sharing options...
Recommended Posts