Jump to content

Promos page accueil, tmspecials.tpl plus de produits et ordre...


MwC

Recommended Posts

Bonjour,

 

J'essais d'afficher plus de produits en promotions sur la page d'accueil via le module TM Specials block v1.0 par TM sur une boutique sous prestashop 1.4.6.2. http://eshop.glissevolution.com/

 

Je pensais qu'en changeant la valeur de {if $smarty.foreach.products.iteration<=14} cela ferais l'affaire, mais apparemment il existe un maximum d'articles affichables... car en dessous de 10 produits cela fonctionne, mais dès que je définie une valeur au dessus de 10 il ne veut rien savoir.

 

A savoir qu'il m'affiche toujours les même produits et dans le même ordre.

 

Merci par avance.

 

Les code du fichier tmspecials.tpl :

<!-- MODULE Block specials -->
<div id="tmspecials" class="block">
<h4><a href="{$link->getPageLink('prices-drop.php')}" title="{l s='Specials' mod='tmspecials'}">{l s='Specials' mod='tmspecials'}</a></h4>
<div class="block_content">
 <ul>
 {foreach from=$products item=product name=products}
 {if $smarty.foreach.products.iteration<=14}
  <li class="ajax_block_product spec{cycle values='1,2,3,4'}">
<a class="product_img_link" href="{$product.link}"><img src="{$link->getImageLink($product.link_rewrite, $product.id_image, 'home')}" alt="{$product.legend|escape:html:'UTF-8'}" title="{$product.name|escape:html:'UTF-8'}" /></a>
<h5><a href="{$product.link}" title="{$product.name|escape:html:'UTF-8'}">{$product.name|escape:html:'UTF-8'}</a></h5>
<span class="price">{if !$priceDisplay}{displayWtPrice p=$product.price}{else}{displayWtPrice p=$product.price_tax_exc}{/if}</span>
<span class="on_sale">
	 - {number_format(((($product.price_without_reduction - $product.price) / $product.price_without_reduction) * 100), 0)}%  </span><span class="price-discount">


				{if !$priceDisplay}{displayWtPrice p=$product.price_without_reduction}{else}{displayWtPrice p=$priceWithoutReduction_tax_excl}{/if}</span>
				<div>
{if ($product.id_product_attribute == 0 || (isset($add_prod_display) && ($add_prod_display == 1))) && $product.available_for_order && !isset($restricted_country_mode) && !$PS_CATALOG_MODE}
 {if ($product.allow_oosp || $product.quantity > 0) && $product.customizable != 2}


  <a class="exclusive ajax_add_to_cart_button" rel="ajax_id_product_{$product.id_product|intval}" href="{$link->getPageLink('cart.php')}?add&id_product={$product.id_product|intval}{if isset($static_token)}&token={$static_token}{/if}" title="{l s='Add to cart'}">{l s='Ajouter au panier' mod='tmspecials'}<span> ></span></a>
 {else}
  <span class="exclusive">{l s='Ajouter au panier' mod='tmspecials'}<span> ></span></span>
 {/if}
{/if}
</div>
  </li>
  {/if}
  {/foreach}
 </ul>
</div>
</div>
<!-- /MODULE Block specials -->
Link to comment
Share on other sites

Personne n'a une idée pour afficher plus de produits sur un module ? :(

 

La fonction {if $smarty.foreach.products.iteration<=14}

est limitée à 10 produits impossible d'en ajouter plus ni de choisir l'ordre et les produits.

Link to comment
Share on other sites

  • 3 months later...

je rajoute le bout de code du fichier php:

{

if (Configuration::get('PS_CATALOG_MODE'))

return ;

global $smarty;

$smarty->assign(array(

'special' => $special,

'products' => Product::getPricesDrop(intval($params['cookie']->id_lang)),

'priceWithoutReduction_tax_excl' => Tools::ps_round($special['price_without_reduction'] / (1 + (int)$special['rate'] / 100), 2),

));

return $this->display(__FILE__, 'tmhomespecials.tpl');

}

}

 

J'ai essayé de mettre le code

shuffle($products);

 

Mais ça me fait une page blanche....

je nage...

 

comment faire pour afficher les promos de façon aléatoires....

j'ai toujours les même 4 produits....

 

si vous avez une idée elle est la bienvenue ;)

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

  • 2 weeks later...

Je viens de trouver une solution pour qu'il prenne les dernières promotions et non les premières (donc à chaque nouvelle promo il les affichera)

 

dans tmspecials.php

public function hookHome($params)
{
 if (Configuration::get('PS_CATALOG_MODE'))
  return ;
 global $smarty;
 $tmp = Product::getPricesDrop(intval($params['cookie']->id_lang), 0, '12', false, '', 'ASC');
 asort($tmp);
 if (!$special = Product::getPricesDrop((int)($params['cookie']->id_lang), 0, '12', false, '', 'ASC') AND !Configuration::get('PS_BLOCK_SPECIALS_DISPLAY'))
  return;
 $smarty->assign(array(
  'special' => $special,
  'specials' => $tmp,
  'products' => Product::getPricesDrop(intval($params['cookie']->id_lang), 0, '12', false, '', 'ASC'),
  'priceWithoutReduction_tax_excl' => Tools::ps_round($special['price_without_reduction'], 2)
 ));
 return $this->display(__FILE__, 'tmspecials.tpl');
}

 

Par contre impossible de mettre plus de 12 ... si quelqu'un à une piste je suis preneur (même en modifiant 12 cela ne fonctionne pas).

Link to comment
Share on other sites

Super, je vais tester. :P

Ce qui serait bien c'est qu'il puisse faire une sorte de "random" des produits en promo, comme le bloc natif prestashop.

Mais là ça dépasse mes compétences....

 

De plus, il serai judicieux qu'il affiche l'ancien prix barré, ce qui n'est pas le cas sur le miens...

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

<?php
if (!defined('_CAN_LOAD_FILES_'))
   exit;
class TMHomeSpecials extends Module
{
   private $_html = '';
   private $_postErrors = array();
   function __construct()
   {
    $this->name = 'tmhomespecials';
    $this->tab = 'pricing_promotion';
    $this->version = 1.0;
    $this->author = 'TM';
    $this->need_instance = 0;
    parent::__construct();
    $this->displayName = $this->l('TM Home Specials');
    $this->description = $this->l('Adds a block with current product specials at a homepage');
   }
   public function install()
   {
    return (parent::install() AND $this->registerHook('home'));
   }
   public function getContent()
   {
    $output = '<h2>'.$this->displayName.'</h2>';
    if (Tools::isSubmit('submitSpecials'))
    {
	    Configuration::updateValue('PS_BLOCK_SPECIALS_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_SPECIALS_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_SPECIALS_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="submitSpecials" value="'.$this->l('Save').'" class="button" /></center>
	    </fieldset>
    </form>';
   }
   public function hookHome($params)
   {
    if (Configuration::get('PS_CATALOG_MODE'))
	    return ;
    global $smarty;
    $smarty->assign(array(
	    'special' => $special,
	    'products' => Product::getPricesDrop(intval($params['cookie']->id_lang)),
	    'priceWithoutReduction_tax_excl' => Tools::ps_round($special['price_without_reduction'] / (1 + (int)$special['rate'] / 100), 2),
    ));
    return $this->display(__FILE__, 'tmhomespecials.tpl');
   }
}

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

Je viens de tester la function shuffle ne fonctionne pas, si tu veux vraiment faire quelque chose pour que ça soit aléatoire il faut que tu fasses comme sur ce lien:

http://www.prestashop.com/forums/topic/67765-solveduse-promotions-articles-into-homepage/

 

MAIS (parce qu'il faut un mais ;)), il faut l'adapter a ta version de prestashop car la function à modifier diffère selon certaines version.

Link to comment
Share on other sites

TU peux aussi modifier le nombre de tes produits en modifiant la valeur dans tmspeecials.php et tmspeacials.tpl (remplacer tous les 12 par 30 par ex).

 

Par contre, tu ne verras la modif qu'en supprimant tous les fichiers (sauf index.php) de tools/smarty/compile/

 

Moi ça fonctionne !

 

Bonne journée !

Link to comment
Share on other sites

  • 1 month later...

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...