Jump to content

[Solucionado]Configuracion modulo mas vendidos (tmbestseller)


Recommended Posts

Hola a todos, desde mi backoffice en el modulo de mas vendidos solo tengo la opcion de "mostrar siempre este bloque", no de deja la opción de decir cuantos items quiero que aparezca.

 

Para modificar dichos items tengo que irme al archivo modules/tmbestseller/tmbesseller.php y modificarlo ahí a mano, pueden decirme que hacer para que se pueda modificar desde el backoffice

Edited by FernandoLopez (see edit history)
Link to comment
Share on other sites

Revisa que no estes confundiendo en la busqueda de los módulos, el módulo que lleva Prestashop por defecto llamado:

Bloque de mejores ventas 

con el

tmbestseller

en tu caso el que tienes que configurar es el llamado:

tmbestseller

que vendra seguramente con otro nombre traducido.

 

De todos modos ¿Cual es el contenido del fichero:

 modules/tmbestseller/tmbesseller.php

?

Link to comment
Share on other sites

pues el contenido es este:

 

<?php
if (!defined('_CAN_LOAD_FILES_'))
exit;
class TMBestSellers extends Module
{
private $_html = '';
private $_postErrors = array();
public function __construct()
{
$this->name = 'tmbestsellers';
$this->tab = 'front_office_features';
$this->version = '1.0';
$this->author = 'TM';
$this->need_instance = 0;
parent::__construct();
$this->displayName = $this->l('TM Top seller block');
$this->description = $this->l('Add a block displaying the shop\'s top sellers.');
}
public function install()
{
if (!parent::install() OR
!$this->registerHook('home') OR
!$this->registerHook('updateOrderStatus') OR
!ProductSale::fillProductSales())
return false;
return true;
}
public function getContent()
{
$output = '<h2>'.$this->displayName.'</h2>';
if (Tools::isSubmit('submitBestSellers'))
{
Configuration::updateValue('PS_BLOCK_BESTSELLERS_DISPLAY', (int)(Tools::getValue('always_display')));
$output .= '<div class="conf confirm"><img src="../img/admin/ok.gif" alt="'.$this->l('Confirmation').'" />'.$this->l('Settings updated').'</div>';
}
return $output.$this->displayForm();
}
public function displayForm()
{
return '
<form action="'.$_SERVER['REQUEST_URI'].'" method="post">
<fieldset>
<legend><img src="'.$this->_path.'logo.gif" alt="" title="" />'.$this->l('Settings').'</legend>
<label>'.$this->l('Always display block').'</label>
<div class="margin-form">
<input type="radio" name="always_display" id="display_on" value="1" '.(Tools::getValue('always_display', Configuration::get('PS_BLOCK_BESTSELLERS_DISPLAY')) ? 'checked="checked" ' : '').'/>
<label class="t" for="display_on"> <img src="../img/admin/enabled.gif" alt="'.$this->l('Enabled').'" title="'.$this->l('Enabled').'" /></label>
<input type="radio" name="always_display" id="display_off" value="0" '.(!Tools::getValue('always_display', Configuration::get('PS_BLOCK_BESTSELLERS_DISPLAY')) ? 'checked="checked" ' : '').'/>
<label class="t" for="display_off"> <img src="../img/admin/disabled.gif" alt="'.$this->l('Disabled').'" title="'.$this->l('Disabled').'" /></label>
<p class="clear">'.$this->l('Show the block even if no product is available.').'</p>
</div>
<center><input type="submit" name="submitBestSellers" value="'.$this->l('Save').'" class="button" /></center>
</fieldset>
</form>';
}
public function hookHome($params)
{
if (Configuration::get('PS_CATALOG_MODE'))
return ;
global $smarty;
$currency = new Currency((int)($params['cookie']->id_currency));
//$bestsellers = ProductSale::getBestSales((int)($params['cookie']->id_lang), 0, 5);
$bestsellers = ProductSale::getBestSales((int)($params['cookie']->id_lang), 0, 8);
if (!$bestsellers AND !Configuration::get('PS_BLOCK_BESTSELLERS_DISPLAY'))
return;
$best_sellers = array();
foreach ($bestsellers AS $bestseller)
{
$bestseller['price'] = Tools::displayPrice(Product::getPriceStatic((int)($bestseller['id_product'])), $currency);
$best_sellers[] = $bestseller;
}
$smarty->assign(array(
'best_sellers' => $best_sellers,
'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY')));
return $this->display(__FILE__, 'tmbestsellers.tpl');
}
}
Link to comment
Share on other sites

A modo rapido, prueba dejarlo asi:

<?php
if (!defined('_CAN_LOAD_FILES_'))
exit;
class TMBestSellers extends Module
{
private $_html = '';
private $_postErrors = array();
public function __construct()
{
$this->name = 'tmbestsellers';
$this->tab = 'front_office_features';
$this->version = '1.0';
$this->author = 'TM';
$this->need_instance = 0;
parent::__construct();
$this->displayName = $this->l('TM Top seller block');
$this->description = $this->l('Add a block displaying the shop\'s top sellers.');
}
public function install()
{

  Configuration::updateValue('HOME_JACK_MOLGAS', 8);

if (!parent::install() OR
!$this->registerHook('home') OR
!$this->registerHook('updateOrderStatus') OR
!ProductSale::fillProductSales())
return false;
return true;
}
public function getContent()
{
$output = '<h2>'.$this->displayName.'</h2>';
if (Tools::isSubmit('submitBestSellers'))
{
                        $nbr_joper = (int)Tools::getValue('nbr_joper');

Configuration::updateValue('PS_BLOCK_BESTSELLERS_DISPLAY', (int)(Tools::getValue('always_display')));
Configuration::updateValue('HOME_JACK_MOLGAS', (int)($nbr_joper));

$output .= '<div class="conf confirm"><img src="../img/admin/ok.gif" alt="'.$this->l('Confirmation').'" />'.$this->l('Settings updated').'</div>';
}
return $output.$this->displayForm();
}
public function displayForm()
{
return '
<form action="'.$_SERVER['REQUEST_URI'].'" method="post">
<fieldset>
<legend><img src="'.$this->_path.'logo.gif" alt="" title="" />'.$this->l('Settings').'</legend>
<label>'.$this->l('Always display block').'</label>
<div class="margin-form">
<input type="radio" name="always_display" id="display_on" value="1" '.(Tools::getValue('always_display', Configuration::get('PS_BLOCK_BESTSELLERS_DISPLAY')) ? 'checked="checked" ' : '').'/>
<label class="t" for="display_on"> <img src="../img/admin/enabled.gif" alt="'.$this->l('Enabled').'" title="'.$this->l('Enabled').'" /></label>
<input type="radio" name="always_display" id="display_off" value="0" '.(!Tools::getValue('always_display', Configuration::get('PS_BLOCK_BESTSELLERS_DISPLAY')) ? 'checked="checked" ' : '').'/>
<label class="t" for="display_off"> <img src="../img/admin/disabled.gif" alt="'.$this->l('Disabled').'" title="'.$this->l('Disabled').'" /></label>
<p class="clear">'.$this->l('Show the block even if no product is available.').'</p>
</div>

  <label>'.$this->l('Define the number of products to be displayed.').'</label>
                                <div class="margin-form">
                                        <input type="text" size="5" name="nbr_joper" value="'.Tools::safeOutput(Tools::getValue('nbr_joper', (int)(Configuration::get('HOME_JACK_MOLGAS')))).'" />
                                        <p class="clear">'.$this->l('Define the number of products that you would like to display on homepage (default: 8).').'</p>

                                </div>

<center><input type="submit" name="submitBestSellers" value="'.$this->l('Save').'" class="button" /></center>
</fieldset>
</form>';
}
public function hookHome($params)
{
if (Configuration::get('PS_CATALOG_MODE'))
return ;
global $smarty;
$currency = new Currency((int)($params['cookie']->id_currency));

  $tengo_poka = (int)Configuration::get('HOME_JACK_MOLGAS');
//$bestsellers = ProductSale::getBestSales((int)($params['cookie']->id_lang), 0, 5);
$bestsellers = ProductSale::getBestSales((int)($params['cookie']->id_lang), 0,  $tengo_poka );
if (!$bestsellers AND !Configuration::get('PS_BLOCK_BESTSELLERS_DISPLAY'))
return;
$best_sellers = array();
foreach ($bestsellers AS $bestseller)
{
$bestseller['price'] = Tools::displayPrice(Product::getPriceStatic((int)($bestseller['id_product'])), $currency);
$best_sellers[] = $bestseller;
}
$smarty->assign(array(
'best_sellers' => $best_sellers,
'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY')));
return $this->display(__FILE__, 'tmbestsellers.tpl');
}
}

Link to comment
Share on other sites

Hola Victor, ha funcionado perfectamente, muchas gracias

 

Un placer ayudarte y servirte!

 

Si das el tema como solucionado, edita el titulo del tema, editando el primer mensaje, pulsando en editar, y después en "Usar editor completo", añadiendo la palabra "Solucionado" al titulo, esto ayudara, a mantener una mayor organización en el foro.

 

Si no sabes como añadir la palabra "Solucionado" al título del tema, aquí tienes una guía: http://www.prestashop.com/forums/topic/269515-solucionado-%C2%BFcomo-poner-la-palabra-solucionado-en-el-titulo-del-tema/

Link to comment
Share on other sites

  • 3 months later...
Guest
This topic is now closed to further replies.
×
×
  • Create New...