Vie Crypto Faucet and PTC
Showing posts with label PrestaShop. Show all posts
Showing posts with label PrestaShop. Show all posts

Install PrestaShop 1.6.1.6 on Windows localhost

Trabla: Install PrestaShop 1.6.1.6 e-commerce on Windows localhost ( XAMPP 5.6.21 )


Install PrestaShop PHP eCommerce shop 1.6.1.6 on Windows tutorial
PrestaShop is a free, open source e-commerce solution. The software is published under the Open Software License (OSL). It is written in the PHP programming language with support for the MySQL database management system.
PrestaShop is currently used by 250,000 shops worldwide and is available in 60 different languages.

Solving:


Watch on YouTube

1. Download and install XAMPP 5.6.21 from official site:
https://www.apachefriends.org/download.html

Install PrestaShop PHP eCommerce shop 1.6.1.6 on Windows tutorial 1

2. Download PrestaShop 1.6.1.6 e-commerce sources from official site:
https://www.prestashop.com/

Install PrestaShop PHP eCommerce shop 1.6.1.6 on Windows tutorial 2

Install PrestaShop PHP eCommerce shop 1.6.1.6 on Windows tutorial 3

Install PrestaShop PHP eCommerce shop 1.6.1.6 on Windows tutorial 4

Install PrestaShop PHP eCommerce shop 1.6.1.6 on Windows tutorial 5


3. Create folder \prestashop XAMPP htdocs folder
C:\xampp\htdocs\prestashop
and copy all files from downloaded PrestaShop 1.6.1.6 e-commerce  .zip source

Install PrestaShop PHP eCommerce shop 1.6.1.6 on Windows tutorial 6


4. Run XAMPP Control Panel 

- open php.ini file ( Apache ->  Config-> PHP(php.ini) )

Install PrestaShop PHP eCommerce shop 1.6.1.6 on Windows tutorial 7


- change max_execution_time value
from max_execution_time=30 to max_execution_time=600

Install PrestaShop PHP eCommerce shop 1.6.1.6 on Windows tutorial 8

Install PrestaShop PHP eCommerce shop 1.6.1.6 on Windows tutorial 9

- save  & close php.ini
- start Apache
- start Database

Install PrestaShop PHP eCommerce shop 1.6.1.6 on Windows tutorial 10

5. Open in browser following url to start  PrestaShop 1.6.1.6 e-commerce  web installation
http://localhost/prestashop

"Choose your language" page of PrestaShop 1.6.1.6 e-commerce  web installation
- click "Next" button

Install PrestaShop PHP eCommerce shop 1.6.1.6 on Windows tutorial 11


6. "License agreement" page of PrestaShop 1.6.1.6 e-commerce  web installation

- enable checkbox "I agree to the above terms and conditions"
- click "Next" button

Install PrestaShop PHP eCommerce shop 1.6.1.6 on Windows tutorial 12


7. "Store information" page of PrestaShop 1.6.1.6 e-commerce  web installation

- type information about your store e.g. shop name, main activity, country etc.
- type your account data ( shop admin credentials )
- click "Next" button

Install PrestaShop PHP eCommerce shop 1.6.1.6 on Windows tutorial 13

8. "System configuration" page of PrestaShop 1.6.1.6 e-commerce  web installation

Install PrestaShop PHP eCommerce shop 1.6.1.6 on Windows tutorial 13


Now we need to create Database for   PrestaShop 1.6.1.6 e-commerce

1) Open phpMyAdmin in new browser tab (or window :) ) - http://localhost/phpmyadmin
2) Open SQL tab
3) Execute following query

Install PrestaShop PHP eCommerce shop 1.6.1.6 on Windows tutorial 14

CREATE DATABASE `prestashop` 
DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;

CREATE USER 'prestashop-owner'@'localhost'; 
CREATE USER 'prestashop-owner'@'127.0.0.1';
CREATE USER 'prestashop-owner'@'::1';

SET PASSWORD 
FOR 'prestashop-owner'@'localhost' = PASSWORD('prestashop123$%');
SET PASSWORD 
FOR 'prestashop-owner'@'127.0.0.1' = PASSWORD('prestashop123$%');
SET PASSWORD 
FOR 'prestashop-owner'@'::1' = PASSWORD('prestashop123$%');


GRANT ALL PRIVILEGES ON 
`prestashop`.* TO 'prestashop-owner'@'localhost' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON 
`prestashop`.* TO 'prestashop-owner'@'127.0.0.1' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON 
`prestashop`.* TO 'prestashop-owner'@'::1' WITH GRANT OPTION;

Install PrestaShop PHP eCommerce shop 1.6.1.6 on Windows tutorial 15

Install PrestaShop PHP eCommerce shop 1.6.1.6 on Windows tutorial 16

Go back  to  PrestaShop 1.6.1.6 e-commerce  installation page

- type Database name -  prestashop
- type Database login - prestashop-owner
- type Database password-  prestashop123$%

- click "Test your database connection now!"

Install PrestaShop PHP eCommerce shop 1.6.1.6 on Windows tutorial 17


- if database connection test successful - click "Next" button

Install PrestaShop PHP eCommerce shop 1.6.1.6 on Windows tutorial 18


9.  Store installation .... please wait ....


Install PrestaShop PHP eCommerce shop 1.6.1.6 on Windows tutorial 19

Install PrestaShop PHP eCommerce shop 1.6.1.6 on Windows tutorial 20

Install PrestaShop PHP eCommerce shop 1.6.1.6 on Windows tutorial 21



10.  Installation finished.

Install PrestaShop PHP eCommerce shop 1.6.1.6 on Windows tutorial 22

Install PrestaShop PHP eCommerce shop 1.6.1.6 on Windows tutorial 23

Install PrestaShop PHP eCommerce shop 1.6.1.6 on Windows tutorial 24


11.  Delete \install folder
e.g. C:\xampp\htdocs\prestashop\install

Install PrestaShop PHP eCommerce shop 1.6.1.6 on Windows tutorial 25


Enjoy   PrestaShop 1.6.1.6 e-commerce !!!

Install PrestaShop PHP eCommerce shop 1.6.1.6 on Windows tutorial 26

Install PrestaShop PHP eCommerce shop 1.6.1.6 on Windows tutorial 27

Install PrestaShop PHP eCommerce shop 1.6.1.6 on Windows tutorial 28

Install PrestaShop PHP eCommerce shop 1.6.1.6 on Windows tutorial 29

Install PrestaShop PHP eCommerce shop 1.6.1.6 on Windows tutorial 30

Install PrestaShop PHP eCommerce shop 1.6.1.6 on Windows tutorial 31

Install PrestaShop PHP eCommerce shop 1.6.1.6 on Windows tutorial 32

Install PrestaShop PHP eCommerce shop 1.6.1.6 on Windows tutorial 33

Install PrestaShop PHP eCommerce shop 1.6.1.6 on Windows tutorial  34

Install PrestaShop PHP eCommerce shop 1.6.1.6 on Windows tutorial  35

Install PrestaShop PHP eCommerce shop 1.6.1.6 on Windows tutorial  36

Install PrestaShop PHP eCommerce shop 1.6.1.6 on Windows tutorial 37

Install PrestaShop PHP eCommerce shop 1.6.1.6 on Windows tutorial 38

Install PrestaShop PHP eCommerce shop 1.6.1.6 on Windows tutorial 39



PrestaShop & php: change admin password in database

Trabla: PrestaShop: change admin password in database

Solving:

1. Get your Presta __COOKIE_KEY__  value, is used for password encryption
Find file settings.inc.php , located in  :
.../prestashop/config/settings.inc.php

Example:

...
define('_MEDIA_SERVER_3_', '');
define('_COOKIE_KEY_', 'aHDAUqwDov63vIkCo4vKUrg0edcA7z0EM6O9rtVnd8BzBGMQqzE2Jbta');
define('_COOKIE_IV_', '1ctPsmVv');

...

2. Execute query in database ( replace red values by yours )

Note: ps_  is table prefix, can be different

UPDATE ps_employee 
SET passwd = md5( 
    CONCAT(
      <COOKIE_KEY> ,  <NEW_PASSWORD>
    )
 ) 
WHERE email = <ADMIN_EMAIL> ;



Example:

UPDATE ps_employee 
SET passwd = md5( 
    CONCAT(
      'aHDAUqwDov63vIkCo4vKUrg0edcA7z0EM6O9rtVnd8BzBGMQqzE2Jbta' ,   
      'pass1234$%'
    )
 ) 
WHERE email = 'admin@mymail.com' ;

PrestaShop: catch Order state change

Trabla: PrestaShop: catch Order state change

Solving:

1. All order state changes are stored in table ps_order_history

2. Order state are changed using class  OrderHistoryCore
located here: .../prestashop/classes/order/OrderHistory.php

3. To override behavior of class OrderHistoryCore
create file OrderHistory.php and put into folder:
.../prestashop/override/classes/order/OrderHistory.php
and declare class this way and override method  changeIdOrderState  :
<?php 
class OrderHistory extends OrderHistoryCore{
      
    //Catch Order State Changes
    public function changeIdOrderState($new_order_state, $id_order, $use_existing_payment = false)
    {

          //COPY CODE from original method HERE   OrderHistoryCore->changeIdOrderState
         //and do your manipulations
         
     }

}

PrestaShop: db table structure for orders,cart,cart product,pack,product, product attribute explanation

Trabla: PrestaShop: db table structure for orders,cart,cart product,pack,product, product attribute  explanation


Solving:
PrestaShop: db table structure for orders,cart,cart product,pack,product, product attribute  explanation

1. One Order - one Cart
2. One Cart has one or more cart products,
each cart product reference to product and
product attribute ( product attribute combinations )
3. Pack is product, includes sub products
Table fields:
id_product_pack - id of product ( id from table ps_product)
id_product_item  - id of product in pack (id from table ps_product )
4. ps_product_attribute_combination - map attribute ( e.g. Color ) with product attribute

Example query to get all products with attributes selected in order:
NOTE: only for standart products!!! Not process packs ( Pack of existing products )

SELECT
                o.id_order
            ,    c.id_cart
            ,    cp.id_product
            ,   pac.id_product_attribute
            ,    a.id_attribute

            ,    a.*
FROM
            ps_orders AS o
INNER JOIN  ps_cart c ON c.id_cart = o.id_cart
INNER JOIN  ps_cart_product AS cp ON cp.id_cart = c.id_cart

INNER JOIN  ps_product_attribute AS pa ON pa.id_product_attribute = cp.id_product_attribute
INNER JOIN  ps_product_attribute_combination AS pac ON pac.id_product_attribute = pa.id_product_attribute
INNER JOIN  ps_attribute AS a ON a.id_attribute = pac.id_attribute

WHERE
            o.id_order = PUT_ORDER_ID_HERE


 

prestashop: remove breadcrumb

Trabla: prestashop: remove breadcrumb


Solving:


1. Find file breadcrum.tpl in your theme folder
e.g.
/prestashop/themes/default-bootstrap/breadcrumb.tpl

2. Change code:

{$my_enable_breadcrumb=false}
{if $my_enable_breadcrumb }


{if isset($smarty.capture.path)}{assign var='path' value=$smarty.capture.path}{/if}
<div class="breadcrumb clearfix">
    <a class="home" href="{$base_dir}" title="{l s='Return to Home'}"><i class="icon-home"></i></a>
    {if isset($path) AND $path}
        <span class="navigation-pipe" {if isset($category) && isset($category->id_category) && $category->id_category == 1}style="display:none;"{/if}>{$navigationPipe|escape:'html':'UTF-8'}</span>
        {if !$path|strpos:'span'}
            <span class="navigation_page">{$path}</span>
        {else}
            {$path}
        {/if}
    {/if}
</div>
{if isset($smarty.get.search_query) && isset($smarty.get.results) && $smarty.get.results > 1 && isset($smarty.server.HTTP_REFERER)}
<div class="pull-right">
    <strong>
        <a href="{$smarty.server.HTTP_REFERER|escape}" name="back">
            <i class="icon-chevron-left left"></i> {l s='Back to Search results for "%s" (%d other results)' sprintf=[$smarty.get.search_query,$smarty.get.results]}
        </a>
    </strong>
</div>
{/if}


{/if}
<!-- /Breadcrumb -->


PrestaShop: get Order Product combination attribute value

Trabla: PrestaShop: Order Product attribute value


Solving:

Orders are strored in table ps_orders
List of items (Products) of Order are stored in table ps_order_details 
(ps_orders to ps_order_details => one to many, one record in ps_orders can have one or many records in ps_order_details )
Each row in ps_order_details has field 'product_attribute_id'  reference to table
ps_attribute_combination - has only two rows "id_attribute" and "id_product_attribute"
"id_attribute" is reference to table ps_attribute


PrestaShop database schema:
http://www.daveegerton.com/assets/images/database-schema-prestashop.png

PrestaShop: add log

Trabla: PrestaShop: add log


Solving:

1. PrestaShop logs are stored in database - table ps_log

2. Logger class defined in :
../prestashop/classes/Logger.php


3. Use in code:

$message = 'This is my test log, my_var  = '.$my_var;
Logger::addLog( $message, 1);

4. Example select from log table (last 10 records):
SELECT * FROM ps_log ORDER BY id_log DESC LIMIT 10;

PrestaShop: Order Statuses for select html element

Trabla: PrestaShop: Order Statuses for select html element

Solving:

$this->context = Context::getContext();
       
        $statuses = OrderState::getOrderStates((int)$this->context->language->id);

       
        $statuses_list = array(
            array(
                'value' => 0,
                'name' => ' - '
            )
        );       

        foreach ($statuses as $status)
        {

            array_push($statuses_list, array(

                    'value'  => $status['id_order_state'],
                    'name'     => $status['name'] . ' (ID='.$status['id_order_state'].')'
            ));
        }


// ... use  $statuses_list as list for select

$this->fields_options = array(
            'general' => array(
                'title' =>    $this->l('My Admin Settings'),
                'icon' =>    'icon-cogs',

                'fields' =>    array(

                    'DO_WHEN_ORDER_STATUS' => array(
                        'title' => $this->l('Do When Order Status'),
                        'hint' => $this->l('Do When Order Status '),
                        'type' => 'select',
                        'list' => $statuses_list,
                        'identifier' => 'value',
                        'validation' => 'isInt',
                        'cast' => 'intval'
                       
                    ),

                ),
                   
                'submit' => array('title' => $this->l('Save'))
            ),
        );

PrestaShop: get context language id

Trabla: PrestaShop: get context language id

Solving:

$id_lang = (int)Context::getContext()->language->id;

Prestashop: Order class location

Trabla: Prestashop: Order class location

Solving:

Order class - OrderCore is located in

../prestashop/classes/order/Order.php

PrestaShop: product special price countdown timer

Trabla: PrestaShop: product special price countdown timer


PrestaShop eCommerce shop -  product special price countdown timer - codingtrabla tutorial 1


















Solving:


1. Add countdown timer code into product details template.

Based on Simple CountDown timer tutorial:
http://codingtrabla.blogspot.com/2014/12/js-simple-count-down-timer.html

Path to template file:
.../prestashop/themes/default-bootstrap/product.tpl

{if !empty($product->unity) && $product->unit_price_ratio > 0.000000}
{math equation="pprice / punit_price"  pprice=$productPrice  punit_price=$product->unit_price_ratio assign=unit_price}
<p class="unit-price"><span id="unit_price_display">{convertPrice price=$unit_price}</span> {l s='per'} {$product->unity|escape:'html':'UTF-8'}</p>
{hook h="displayProductPriceBlock" product=$product type="unit_price"}
{/if}
{/if} {*close if for show price*}
{hook h="displayProductPriceBlock" product=$product type="weight"}
<div class="clear"></div>
</div> <!-- end content_prices -->
<div class="product_attributes clearfix">




<style>
  .simple-countdown-labels{
   font-size: small;
   text-align: center;
  }
  .simple-countdown-nums{
   font-size: xx-large;
   text-align: center;
   color: red;
  }
  .simple-countdown-cell{
   border-style: solid;
      border-color: #ff0000 #00ff00 #0000ff rgb(250,0,255);
  }
 </style>

<div id='simple-countdown' style="display:none;">
<h3>Time Left:</h3>
 <table>
 <tbody class="simple-countdown-nums">
  <tr>
   <td>
    <span id="simple-countdown-days" class="simple-countdown-cell">00</span>
   </td>
   <td>
    <span id="simple-countdown-hours" class="simple-countdown-cell">00</span>
   </td>
   <td>
    <span id="simple-countdown-minutes" class="simple-countdown-cell">00</span>
   </td>
   <td>
    <span id="simple-countdown-seconds" class="simple-countdown-cell">00</span>
   </td>
  </tr>
 </tbody>
 <tfoot class="simple-countdown-labels">
  <tr>
   <td>Days&nbsp;</td>
   <td>Hours</td>
   <td>Min&nbsp;&nbsp;</td>
   <td>Sec&nbsp;&nbsp;</td>
  </tr>
 </tfoot>
 </table>
</div>

<script type="text/javascript" >
  function SimpleCountDown( from, to , daysId, hoursId, minId, secId ){

    
   var from = Date.parse(from);
   var to = Date.parse(to);

    var interval = 0; //in milliseconds
   var days = document.getElementById(daysId);
   var hours = document.getElementById(hoursId);
   var minutes = document.getElementById(minId);
   var seconds = document.getElementById(secId);
   var timer;

    var self = this;

   this.init = function( ){

    interval =  to - from ;
   
   this.updateCountDown();

    timer = setInterval( this.updateCountDown, 1000);

   };

   this.millisecondsToDaysHoursMinutesSeconds = function( milliSeconds ){
  
   var milliseconds, days, hours, minutes, seconds; 

    if( milliSeconds > 0 ){

     milliseconds = milliSeconds;
    days   = Math.floor( milliseconds / ( 24 * 60 * 60 * 1000 ) );
    if ( days < 0 ) { days = 0; }  
    milliseconds  -= days * 24 * 60 * 60 * 1000;

     hours   = Math.floor( milliseconds / ( 60 * 60 * 1000 ) );
    if ( hours < 0 ) { hours = 0; } 
    milliseconds  -= hours * 60 * 60 * 1000;

     minutes  = Math.floor( milliseconds / ( 60 * 1000 ) );
    if ( minutes < 0 ) { minutes = 0; } 
    milliseconds  -= minutes * 60 * 1000;

     seconds  = Math.floor( milliseconds / ( 1000 ) );
    if ( seconds < 0 ) { seconds = 0; }

    }else{
    days = hours = minutes = seconds = 0;
   }
   
   var result = new Object;
   result.days = days;
   result.hours = hours;
   result.minutes = minutes;
   result.seconds = seconds;

   return result;
  };

   this.updateCountDown = function(){

    if( interval > 0 ){
    interval = interval - 1000;
   }else{
    interval = 0;
   }

    var left = self.millisecondsToDaysHoursMinutesSeconds( interval );

    days.innerHTML   = left.days < 10 ? '0' + left.days : left.days;
   hours.innerHTML  = left.hours < 10 ? '0' + left.hours : left.hours;
   minutes.innerHTML  = left.minutes < 10 ? '0' + left.minutes : left.minutes;
   seconds.innerHTML  = left.seconds < 10 ? '0' + left.seconds : left.seconds;
   
  };

   


  };

  if( product_specific_price !== undefined ){
  if( product_specific_price.from !== undefined ){
  if( product_specific_price.to !== undefined ){
 
  //Display SimpleCountDown view
  var container = document.getElementById('simple-countdown');
  container.style.cssText += "display : block";

  var countdown = new SimpleCountDown( 
  product_specific_price.from
 ,  product_specific_price.to
 , 'simple-countdown-days'
 , 'simple-countdown-hours'
 , 'simple-countdown-minutes'
 , 'simple-countdown-seconds'

  );
countdown.init();

  }
  }
  }


  

</script>







<!-- quantity wanted -->
{if !$PS_CATALOG_MODE}
<p id="quantity_wanted_p"{if (!$allow_oosp && $product->quantity <= 0) || !$product->available_for_order || $PS_CATALOG_MODE} style="display: none;"{/if}>
<label>{l s='Quantity'}</label>


2.  Add special(specific) price with interval in admin dashboard

PrestaShop eCommerce shop -  product special price countdown timer - codingtrabla tutorial 2

PrestaShop: add custom field into registration and profile pages

Trabla: PrestaShop: add custom  field into registeration and profile pages


PrestaShop eCommerce shop - howto add custom  field into registration and profile pages - codingtrabla tutorial 1


PrestaShop eCommerce shop - howto add custom  field into registration and profile pages - codingtrabla tutorial 2

PrestaShop eCommerce shop - howto add custom  field into registration and profile pages - codingtrabla tutorial 3


Solving:


1. Add new field 'favorite_hero' into 'ps_customer' table

ALTER TABLE `ps_customer` ADD COLUMN `favorite_hero` varchar(255) DEFAULT NULL;

2. Create file Customer.php in  /override/classes/ folder and copy following code (extending CustomerCore class):

<?php

class Customer extends CustomerCore {

    public $favorite_hero = null;

    /**
     * this is default definition from CustomerCore class + new custom field 
     * "favorite_hero"
     */
    public static $definition = array(
        'table' => 'customer',
        'primary' => 'id_customer',
        'fields' => array(
            'secure_key' => array('type' => self::TYPE_STRING, 'validate' => 'isMd5', 'copy_post' => false),
            'lastname' => array('type' => self::TYPE_STRING, 'validate' => 'isName', 'required' => true, 'size' => 32),
            'firstname' => array('type' => self::TYPE_STRING, 'validate' => 'isName', 'required' => true, 'size' => 32),
            'email' => array('type' => self::TYPE_STRING, 'validate' => 'isEmail', 'required' => true, 'size' => 128),
            'passwd' => array('type' => self::TYPE_STRING, 'validate' => 'isPasswd', 'required' => true, 'size' => 32),
            'last_passwd_gen' => array('type' => self::TYPE_STRING, 'copy_post' => false),
            'id_gender' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
            'birthday' => array('type' => self::TYPE_DATE, 'validate' => 'isBirthDate'),
            'newsletter' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
            'newsletter_date_add' => array('type' => self::TYPE_DATE, 'copy_post' => false),
            'ip_registration_newsletter' => array('type' => self::TYPE_STRING, 'copy_post' => false),
            'optin' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
            'website' => array('type' => self::TYPE_STRING, 'validate' => 'isUrl'),
            'company' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName'),
            'siret' => array('type' => self::TYPE_STRING, 'validate' => 'isSiret'),
            'ape' => array('type' => self::TYPE_STRING, 'validate' => 'isApe'),
            'outstanding_allow_amount' => array('type' => self::TYPE_FLOAT, 'validate' => 'isFloat', 'copy_post' => false),
            'show_public_prices' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool', 'copy_post' => false),
            'id_risk' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt', 'copy_post' => false),
            'max_payment_days' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt', 'copy_post' => false),
            'active' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool', 'copy_post' => false),
            'deleted' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool', 'copy_post' => false),
            'note' => array('type' => self::TYPE_HTML, 'validate' => 'isCleanHtml', 'size' => 65000, 'copy_post' => false),
            'is_guest' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool', 'copy_post' => false),
            'id_shop' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'copy_post' => false),
            'id_shop_group' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'copy_post' => false),
            'id_default_group' => array('type' => self::TYPE_INT, 'copy_post' => false),
            'id_lang' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'copy_post' => false),
            'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate', 'copy_post' => false),
            'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate', 'copy_post' => false),
            
            ///custom field 
            'favorite_hero' => array('type' => self::TYPE_STRING ),
        ),
    );

}


3. Modify authentication.tpl ( is used to render registation form).
Path to file ../prestashop/themes/default-bootstrap/authentication.tpl

<form action="{$link->getPageLink('authentication', true)|escape:'html':'UTF-8'}" method="post" id="account-creation_form" class="std box">
{$HOOK_CREATE_ACCOUNT_TOP}
<div class="account_creation">
<h3 class="page-subheading">{l s='Your personal information'}</h3>
<div class="clearfix">
<label>{l s='Title'}</label>
<br />
{foreach from=$genders key=k item=gender}
<div class="radio-inline">
<label for="id_gender{$gender->id}" class="top">
<input type="radio" name="id_gender" id="id_gender{$gender->id}" value="{$gender->id}" {if isset($smarty.post.id_gender) && $smarty.post.id_gender == $gender->id}checked="checked"{/if} />
{$gender->name}
</label>
</div>
{/foreach}
</div>
<div class="required form-group">
<label for="customer_firstname">{l s='First name'} <sup>*</sup></label>
<input onkeyup="$('#firstname').val(this.value);" type="text" class="is_required validate form-control" data-validate="isName" id="customer_firstname" name="customer_firstname" value="{if isset($smarty.post.customer_firstname)}{$smarty.post.customer_firstname}{/if}" />
</div>
<div class="required form-group">
<label for="customer_lastname">{l s='Last name'} <sup>*</sup></label>
<input onkeyup="$('#lastname').val(this.value);" type="text" class="is_required validate form-control" data-validate="isName" id="customer_lastname" name="customer_lastname" value="{if isset($smarty.post.customer_lastname)}{$smarty.post.customer_lastname}{/if}" />
</div>
<div class="required form-group">
<label for="email">{l s='Email'} <sup>*</sup></label>
<input type="text" class="is_required validate form-control" data-validate="isEmail" id="email" name="email" value="{if isset($smarty.post.email)}{$smarty.post.email}{/if}" />
</div>
<div class="required password form-group">
<label for="passwd">{l s='Password'} <sup>*</sup></label>
<input type="password" class="is_required validate form-control" data-validate="isPasswd" name="passwd" id="passwd" />
<span class="form_info">{l s='(Five characters minimum)'}</span>
</div> 
                        
                        <!-- Start Custom Field -->
                        <div class="form-group">
                             <label for="favorite_hero">{l s='Favorite Hero'} </label>
                             <input class="form-control" type="text"  id="favorite_hero" name="favorite_hero" value="{$smarty.post.favorite_hero}" />
                        </div>
                                        
                        <!-- End Custom Field -->
                                       
                        
<div class="form-group">
<label>{l s='Date of Birth'}</label>
<div class="row">

4. Modify  identity.tpl (is used to render profile page )
Path to file ../prestashop/themes/default-bootstrap/identity.tpl

     <input class="is_required validate form-control" data-validate="isName" type="text" name="lastname" id="lastname" value="{$smarty.post.lastname}" />
                </div>
                <div class="required form-group">
                    <label for="email" class="required">
                        {l s='E-mail address'} 
                    </label>
                    <input class="is_required validate form-control" data-validate="isEmail" type="email" name="email" id="email" value="{$smarty.post.email}" />
                </div>
                
                
                
                <!-- Start Custom Field -->
                        <div class="form-group">
                             <label for="favorite_hero">{l s='Favorite Hero'} </label>
                             <input class="form-control" type="text"  id="favorite_hero" name="favorite_hero" value="{$smarty.post.favorite_hero}" />
                        </div>
                                        
                <!-- End Custom Field -->
                
                
                <div class="form-group">
                    <label>
                        {l s='Date of Birth'}
                    </label>

PrestaShop: Product Youtube Video

Trabla: PrestaShop - Product Youtube Video


PrestaShop eCommerce shop - add  Product Youtube Video to shop template - codingtrabla tutorial 1

Admin Product Edit Form:

PrestaShop eCommerce shop - add  Product Youtube Video to shop template - codingtrabla tutorial 2

Environment: PrestaShop v1.6.0.9

Solving Overview:
1. Add column "youtube_url" into "ps_product" table
2. Extend ProductCore class into Product using PrestaShop override principle - add support of new field.
3. Change Admin template "informations.tpl" - add support of "youtube_url"
4. Change theme tempalete "product.tpl" - add youtube iframe
5. Clear shop cache



Solving Details:
1. Add column "youtube_url" into "ps_product" table

ALTER TABLE `ps_product` ADD COLUMN `youtube_url` varchar(500) DEFAULT NULL;

2. Extend ProductCore class into Product using PrestaShop override principle - add support of new field:
- create file Product.php
- copy file into folder .../prestashop/override/classes/
- edit file .../prestashop/override/classes/Product.php add following code

<?php

/**
 * Description of Product
 *
 * @author samuraikit
 */
class Product extends ProductCore {
   
    public $youtube_url = '';
    
    public static $definition = array(
'table' => 'product',
'primary' => 'id_product',
'multilang' => true,
'multilang_shop' => true,
'fields' => array(
// Classic fields
'id_shop_default' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
'id_manufacturer' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
'id_supplier' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
'reference' => array('type' => self::TYPE_STRING, 'validate' => 'isReference', 'size' => 32),
'supplier_reference' => array('type' => self::TYPE_STRING, 'validate' => 'isReference', 'size' => 32),
'location' => array('type' => self::TYPE_STRING, 'validate' => 'isReference', 'size' => 64),
'width' => array('type' => self::TYPE_FLOAT, 'validate' => 'isUnsignedFloat'),
'height' => array('type' => self::TYPE_FLOAT, 'validate' => 'isUnsignedFloat'),
'depth' => array('type' => self::TYPE_FLOAT, 'validate' => 'isUnsignedFloat'),
'weight' => array('type' => self::TYPE_FLOAT, 'validate' => 'isUnsignedFloat'),
'quantity_discount' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
'ean13' => array('type' => self::TYPE_STRING, 'validate' => 'isEan13', 'size' => 13),
                    
                        //Youtube Url
                        'youtube_url' => array('type' => self::TYPE_STRING, 'validate' => 'isUrl', 'size' => 500),
                    
'upc' => array('type' => self::TYPE_STRING, 'validate' => 'isUpc', 'size' => 12),
'cache_is_pack' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
'cache_has_attachments' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
'is_virtual' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),

/* Shop fields */
'id_category_default' => array('type' => self::TYPE_INT, 'shop' => true, 'validate' => 'isUnsignedId'),
'id_tax_rules_group' => array('type' => self::TYPE_INT, 'shop' => true, 'validate' => 'isUnsignedId'),
'on_sale' => array('type' => self::TYPE_BOOL, 'shop' => true, 'validate' => 'isBool'),
'online_only' => array('type' => self::TYPE_BOOL, 'shop' => true, 'validate' => 'isBool'),
'ecotax' => array('type' => self::TYPE_FLOAT, 'shop' => true, 'validate' => 'isPrice'),
'minimal_quantity' => array('type' => self::TYPE_INT, 'shop' => true, 'validate' => 'isUnsignedInt'),
'price' => array('type' => self::TYPE_FLOAT, 'shop' => true, 'validate' => 'isPrice', 'required' => true),
'wholesale_price' => array('type' => self::TYPE_FLOAT, 'shop' => true, 'validate' => 'isPrice'),
'unity' => array('type' => self::TYPE_STRING, 'shop' => true, 'validate' => 'isString'),
'unit_price_ratio' => array('type' => self::TYPE_FLOAT, 'shop' => true),
'additional_shipping_cost' => array('type' => self::TYPE_FLOAT, 'shop' => true, 'validate' => 'isPrice'),
'customizable' => array('type' => self::TYPE_INT, 'shop' => true, 'validate' => 'isUnsignedInt'),
'text_fields' => array('type' => self::TYPE_INT, 'shop' => true, 'validate' => 'isUnsignedInt'),
'uploadable_files' => array('type' => self::TYPE_INT, 'shop' => true, 'validate' => 'isUnsignedInt'),
'active' => array('type' => self::TYPE_BOOL, 'shop' => true, 'validate' => 'isBool'),
'redirect_type' => array('type' => self::TYPE_STRING, 'shop' => true, 'validate' => 'isString'),
'id_product_redirected' => array('type' => self::TYPE_INT, 'shop' => true, 'validate' => 'isUnsignedId'),
'available_for_order' => array('type' => self::TYPE_BOOL, 'shop' => true, 'validate' => 'isBool'),
'available_date' => array('type' => self::TYPE_DATE, 'shop' => true, 'validate' => 'isDateFormat'),
'condition' => array('type' => self::TYPE_STRING, 'shop' => true, 'validate' => 'isGenericName', 'values' => array('new', 'used', 'refurbished'), 'default' => 'new'),
'show_price' => array('type' => self::TYPE_BOOL, 'shop' => true, 'validate' => 'isBool'),
'indexed' => array('type' => self::TYPE_BOOL, 'shop' => true, 'validate' => 'isBool'),
'visibility' => array('type' => self::TYPE_STRING, 'shop' => true, 'validate' => 'isProductVisibility', 'values' => array('both', 'catalog', 'search', 'none'), 'default' => 'both'),
'cache_default_attribute' => array('type' => self::TYPE_INT, 'shop' => true),
'advanced_stock_management' => array('type' => self::TYPE_BOOL, 'shop' => true, 'validate' => 'isBool'),
'date_add' => array('type' => self::TYPE_DATE, 'shop' => true, 'validate' => 'isDateFormat'),
'date_upd' => array('type' => self::TYPE_DATE, 'shop' => true, 'validate' => 'isDateFormat'),

/* 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,
'ws_modifier' => array(
'http_method' => WebserviceRequest::HTTP_POST,
'modifier' => 'modifierWsLinkRewrite'
)
),
'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'),
'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),
),
'associations' => array(
'manufacturer' => array('type' => self::HAS_ONE),
'supplier' => array('type' => self::HAS_ONE),
'default_category' => array('type' => self::HAS_ONE, 'field' => 'id_category_default', 'object' => 'Category'),
'tax_rules_group' => array('type' => self::HAS_ONE),
'categories' => array('type' => self::HAS_MANY, 'field' => 'id_category', 'object' => 'Category', 'association' => 'category_product'),
'stock_availables' => array('type' => self::HAS_MANY, 'field' => 'id_stock_available', 'object' => 'StockAvailable', 'association' => 'stock_availables'),
),
);
}

3. Change Admin template "informations.tpl" - add support of "youtube_url"

File is located in admin folder
.../prestashop/admin3652/themes/default/template/controllers/products/informations.tpl
where admin3652 is admin folder, should be changed to yours


<div class="form-group">
<label class="control-label col-lg-3" for="upc">
<span class="label-tooltip" data-toggle="tooltip"
title="{l s='This type of product code is widely used in the United States, Canada, the United Kingdom, Australia, New Zealand and in other countries.'}">
{$bullet_common_field} {l s='UPC barcode'}
</span>
</label>
<div class="col-lg-3">
<input maxlength="12" type="text" id="upc" name="upc" value="{$product->upc|escape:'html':'UTF-8'}" />
</div>
</div>
             
        <!-- SamuraiKit START -->        
        <div class="form-group">
<label class="control-label col-lg-3" for="youtube_url">
<span class="label-tooltip" data-toggle="tooltip"
title="{l s='YouTube Url'}">
{$bullet_common_field} {l s='YouTube Url'}
</span>
</label>
<div class="col-lg-3">
<input maxlength="500" type="text" id="youtube_url" name="youtube_url" value="{$product->youtube_url|escape:'html':'UTF-8'}" />
</div>
</div>
        <!-- SamuraiKit End -->    

<hr/>

{* status informations *}
<div class="form-group">
<div class="col-lg-1"><span class="pull-right">{include file="controllers/products/multishop/checkbox.tpl" field="active" type="radio" onclick=""}</span></div>
<label class="control-label col-lg-2">
{l s='Enabled'}
</label>
<div class="col-lg-9">



4. Change theme tempalete "product.tpl" - add youtube iframe
File is located in admin folder
.../prestashop/themes/default-bootstrap/product.tpl

<span>{l s='Up to'}</span>
{if $quantity_discount.price >= 0 || $quantity_discount.reduction_type == 'amount'}
{$discountPrice=$productPrice-$quantity_discount.real_value|floatval}
{else}
{$discountPrice=$productPrice-($productPrice*$quantity_discount.reduction)|floatval}
{/if}
{$discountPrice=$discountPrice*$quantity_discount.quantity}
{$qtyProductPrice = $productPrice*$quantity_discount.quantity}
{convertPrice price=$qtyProductPrice-$discountPrice}
</td>
</tr>
{/foreach}
</tbody>
</table>
</div>
</section>
                                                
                       
{/if}
             
             
             <!-- SamuraiKit START -->
                {if isset($product->youtube_url) }
                    <iframe width="640" height="360" src="{$product->youtube_url}" frameborder="0" allowfullscreen></iframe>
                {/if}
                <!-- SamuraiKit END -->
             
             
             
{if isset($features) && $features}
<!-- Data sheet -->
<section class="page-product-box">
<h3 class="page-product-heading">{l s='Data sheet'}</h3>
<table class="table-data-sheet">
{foreach from=$features item=feature}
<tr class="{cycle values="odd,even"}">
{if isset($feature.value)}
<td>{$feature.name|escape:'html':'UTF-8'}</td>
<td>{$feature.value|escape:'html':'UTF-8'}</td>
{/if}
</tr>
{/foreach}
</table>
</section>
<!--end Data sheet -->
{/if}
{if $product->description}



5. Clear shop cache

Note: use YouTube embed url

PrestaShop eCommerce shop - add  Product Youtube Video to shop template - codingtrabla tutorial 3





















Check out source files on GitHub:
https://github.com/samuraikit/prestashop-product-youtube