Jump to content

Edit History

gabrielio

gabrielio

Thanks for the solution, i solved it like this:

1. Create the override file ProductController.php (like @NemoPS mentioned in his tutorial link) containing the code shown below and upload the file to override/controllers/front

<?php
 
class ProductController extends ProductControllerCore
{
    public function setMedia()
{
    parent::setMedia();
 
    if (Configuration::get('PS_COMPARATOR_MAX_ITEM'))
        $this->addJS(_THEME_JS_DIR_.'products-comparison.js');
}
public function initContent()
{
 
    $this->context->smarty->assign('comparator_max_item', Configuration::get('PS_COMPARATOR_MAX_ITEM'));
     
    if (isset($this->context->cookie->id_compare))
        $this->context->smarty->assign('compareProducts', CompareProduct::getCompareProducts((int)$this->context->cookie->id_compare));
 
    parent::initContent();
}   
}
?>

 

2. In product.tpl  add the following code (like @kosm12 mentioned) where you want the "add to compare" button to appear. You can customise the check button using css before and after.

<div class="compare_product_page">    
            {if isset($comparator_max_item) && $comparator_max_item}
            <div class="compare">
            <a class="add_to_compare" href="#" data-id-product="{$product->id|intval}">{l s='Add to Compare'}</a>
            </div>
            {/if}
            {include file="./product-compare.tpl"}
            </div>

            {*Products compare *}
            {addJsDefL name=min_item}{l s='Please select at least one product' js=1}{/addJsDefL}
            {addJsDefL name=max_item}{l s='You cannot add more than %d product(s) to the product comparison' sprintf=$comparator_max_item js=1}{/addJsDefL}
            {addJsDef comparator_max_item=$comparator_max_item}
            {addJsDef comparedProductsIds=$compared_products}

 

You can see the results live, here: https://laptop-hunter.com/notebook-hp-15-dw0012na-6pc36ea-silver-6098.html

 

PS: I forgot to mention that i use Prestashop 1.6.1.18.

Thank you!

gabrielio

gabrielio

Thanks for the solution, i solved it like this:

1. Create the override file ProductController.php (like @NemoPS mentioned in his tutorial link) containing the code shown below and upload the file to override/controllers/front

<?php
 
class ProductController extends ProductControllerCore
{
    public function setMedia()
{
    parent::setMedia();
 
    if (Configuration::get('PS_COMPARATOR_MAX_ITEM'))
        $this->addJS(_THEME_JS_DIR_.'products-comparison.js');
}
public function initContent()
{
 
    $this->context->smarty->assign('comparator_max_item', Configuration::get('PS_COMPARATOR_MAX_ITEM'));
     
    if (isset($this->context->cookie->id_compare))
        $this->context->smarty->assign('compareProducts', CompareProduct::getCompareProducts((int)$this->context->cookie->id_compare));
 
    parent::initContent();
}   
}
?>

 

2. In product.tpl  add the following code (like @kosm12 mentioned) where you want the "add to compare" button to appear. You can customise the check button using css before and after.

<div class="compare_product_page">    
            {if isset($comparator_max_item) && $comparator_max_item}
            <div class="compare">
            <a class="add_to_compare" href="#" data-id-product="{$product->id|intval}">{l s='Add to Compare'}</a>
            </div>
            {/if}
            {include file="./product-compare.tpl"}
            </div>

            {*Products compare *}
            {addJsDefL name=min_item}{l s='Please select at least one product' js=1}{/addJsDefL}
            {addJsDefL name=max_item}{l s='You cannot add more than %d product(s) to the product comparison' sprintf=$comparator_max_item js=1}{/addJsDefL}
            {addJsDef comparator_max_item=$comparator_max_item}
            {addJsDef comparedProductsIds=$compared_products}

 

You can see the results live, here: https://laptop-hunter.com/notebook-hp-15-dw0012na-6pc36ea-silver-6098.html

 

PS: I forgot to mention that i use Prestashop 1.6.1.18.

Thank you!

gabrielio

gabrielio

Thanks for the solution, i solved it like this:

1. Create the override file ProductController.php (like @NemoPS mentioned in his tutorial link) containing the code shown below and upload the file to override/controllers/front

<?php
 
class ProductController extends ProductControllerCore
{
    public function setMedia()
{
    parent::setMedia();
 
    if (Configuration::get('PS_COMPARATOR_MAX_ITEM'))
        $this->addJS(_THEME_JS_DIR_.'products-comparison.js');
}
public function initContent()
{
 
    $this->context->smarty->assign('comparator_max_item', Configuration::get('PS_COMPARATOR_MAX_ITEM'));
     
    if (isset($this->context->cookie->id_compare))
        $this->context->smarty->assign('compareProducts', CompareProduct::getCompareProducts((int)$this->context->cookie->id_compare));
 
    parent::initContent();
}   
}
?>

2. In product.tpl  add the following code (like @kosm12 mentioned) where you want the "add to compare" button to appear. You can customise the check button using css before and after.
 

<div class="compare_product_page">    
            {if isset($comparator_max_item) && $comparator_max_item}
            <div class="compare">
            <a class="add_to_compare" href="#" data-id-product="{$product->id|intval}">{l s='Add to Compare'}</a>
            </div>
            {/if}
            {include file="./product-compare.tpl"}
            </div>

            {*Products compare *}
            {addJsDefL name=min_item}{l s='Please select at least one product' js=1}{/addJsDefL}
            {addJsDefL name=max_item}{l s='You cannot add more than %d product(s) to the product comparison' sprintf=$comparator_max_item js=1}{/addJsDefL}
            {addJsDef comparator_max_item=$comparator_max_item}
            {addJsDef comparedProductsIds=$compared_products}

You can see the results live, here: https://laptop-hunter.com/notebook-hp-15-dw0012na-6pc36ea-silver-6098.html

 

×
×
  • Create New...