Jump to content

Colors on product-list.tpl


Recommended Posts

i just used firebug to check and there is color picker. but it is blank in the div

<div class="color_picker"> </div>

I had tried on another site with a fresh installation and it can work!!!

 

Not sure what is causing this issue to block the command...

 

anyone got any idea?

Link to comment
Share on other sites

i got it resolved with the help of DH!!! Thanks DH!!!

 

he just enabled layered navigation block and it back online!!!


rob what is your issue?

 

follow these steps and you should be good to go.



/home/lovelyin/public_html/themes/alysum_2.0/css/product_list.css
(any location of the file is ok.)

#product_list li .color_picker span {
	border: 1px solid #C0C0C0;
	display: inline-block;
	height: 14px;
	width: 8px;
}

/home/lovelyin/public_html/themes/alysum_2.0/product-list.tpl
(it should be placed within <div class="center_block">, also I have placed it after the title of the product. I placed it after 
{if isset($product.new) && $product.new == 1}<span class="new">{l s='New'}</span>{/if}</a>
)

						<!-- START color picker -->
						<div class="color_picker">
						<!-- disable color, will be using "more colors text"
						{if isset($product.colors)}{foreach from=$product.colors item=v}
						<span style="background: {$v.value};" title="{$v.name}"></span>{/foreach}
						{/if}
						-->
						{if !empty($product.colors)} 
							<font color="#9933ff">More Colors</font>
						{/if} 
						</div>
						<!-- END color picker -->

/home/lovelyin/public_html/modules/blocklayered/blocklayered.php
(Place the code after this
$products = Product::getProductsProperties((int)$cookie->id_lang, $products);
)

//START color picker
foreach ($products as $key => $product_item) {
$product = new Product($product_item['id_product'], false, $cookie->id_lang);
$colors = array();
$attributes_groups = $product->getAttributesGroups($cookie->id_lang);
if (is_array($attributes_groups) && $attributes_groups)
{
foreach ($attributes_groups as $k => $row)
{
// Color management
if ((isset($row['attribute_color']) && $row['attribute_color']) || (file_exists(_PS_COL_IMG_DIR_.$row['id_attribute'].'.jpg')))
{
$colors[$row['id_attribute']]['value'] = $row['attribute_color'];
$colors[$row['id_attribute']]['name'] = $row['attribute_name'];
}
}
$products[$key]['colors'] = $colors;
}
}
//END color picker

Someone can help !?!?!?

 

Thanks

Link to comment
Share on other sites

 

i got it resolved with the help of DH!!! Thanks DH!!!

 

he just enabled layered navigation block and it back online!!!

rob what is your issue?

 

 

Hello. The problem is that in product-list.tpl, for each products, the colors show up correctly, but the custom texture not. This is the code that I have:

<div style="display:block;height:20px;">
{if !empty($product.colors)}
<div style="float:left">
	<span style="float:left">Colore:</span>
    {foreach from=$product.colors key=id_attribute item=color}
		 <span class="color_picker" style="background: {$color.value};" title="{$color.name}"></span>
    {/foreach}
</div>{/if}</div>

Instead of image texture, it shows the background color of the texture (which can be chosen when uploading the texture in BO).

 

Watch the 2 screenshots :)

 

 

Thanks.

post-183518-0-42351800-1378821533_thumb.jpg

post-183518-0-56580800-1378821794_thumb.jpg

Link to comment
Share on other sites

What happens when you remove the #ffffff from the attribute value? The attribute value can in reality only use a color or an image, it might be getting confused because you are using both. Also is there a link to one of the category pages that you are talking about?

Link to comment
Share on other sites

What happens when you remove the #ffffff from the attribute value?

 

Simple I get this output:

<span title="Tela 100% cotone" style="background: ;" class="color_picker"></span>

As you see "background" property is empty, it should be:

<span title="Tela 100% cotone" style="background:url(/img/co/24.jpg) ;" class="color_picker"></span>

This is my /override/controllers/CategoryController.php file:

	foreach ($this->cat_products as $key => $cat_product) {
						$product = new Product(intval($cat_product['id_product']), true, intval(self::$cookie->id_lang));
						$colors = array();
						
						$groupcolor = 1;
						/* O pour afficher aussi les produits hors stock*/
						$prodquantity = 1;
						
						$attributesGroups = Db::getInstance()->ExecuteS('
						SELECT pai.`id_image`, ag.`id_attribute_group`, ag.`is_color_group`, agl.`name` AS group_name, agl.`public_name` AS public_group_name, a.`id_attribute`, al.`name` AS attribute_name,
						a.`color` AS attribute_color, pa.`id_product_attribute`, pa.`quantity`, pa.`price`, pa.`ecotax`, pa.`weight`, pa.`default_on`, pa.`reference`, pa.`unit_price_impact`, pa.`minimal_quantity`
						FROM `' . _DB_PREFIX_ . 'product_attribute` pa
						LEFT JOIN `' . _DB_PREFIX_ . 'product_attribute_combination` pac ON pac.`id_product_attribute` = pa.`id_product_attribute`
						LEFT JOIN `' . _DB_PREFIX_ . 'product_attribute_image` pai ON pai.`id_product_attribute` = pa.`id_product_attribute`
						LEFT JOIN `' . _DB_PREFIX_ . 'attribute` a ON a.`id_attribute` = pac.`id_attribute`
						LEFT JOIN `' . _DB_PREFIX_ . 'attribute_group` ag ON ag.`id_attribute_group` = a.`id_attribute_group`
						LEFT JOIN `' . _DB_PREFIX_ . 'attribute_lang` al ON a.`id_attribute` = al.`id_attribute`
						LEFT JOIN `' . _DB_PREFIX_ . 'attribute_group_lang` agl ON ag.`id_attribute_group` = agl.`id_attribute_group`
						WHERE pa.`id_product` =  '.$cat_product['id_product'].'
						AND al.`id_lang` =  '.self::$cookie->id_lang.'
						AND agl.`id_lang` = '.self::$cookie->id_lang.'
						AND ag.`is_color_group` = '.$groupcolor.'
						AND pa.quantity >= '.$prodquantity.'
						');
						if (Db::getInstance()->numRows())
						{
							foreach ($attributesGroups AS $k => $row)
							{
								/* Color management */
								if (isset($row['attribute_color']) AND $row['attribute_color'] AND $row['id_attribute_group'] == $product->id_color_default)
								{
									$colors[$row['id_attribute']]['value'] = $row['attribute_color'];
									$colors[$row['id_attribute']]['name']  = $row['attribute_name'];
									$colors[$row['id_attribute']]['id_image']  =(($row['id_image'] != NULL) ? intval($row['id_image']) : -1);
								}
							}
						}
						$this->cat_products[$key]['colors'] = $colors;
					}

It seems that $color.value, doesn't achieve the uploaded texture image url in product-list.tpl . How can be solved ?T

 

thank you

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

I solved changing product-list.tpl file:

<span class="color_picker" style="background: {$color.value};" title="{$color.name}"></span>

in:

<span class="color_picker" style="background: url(/img/co/{$id_attribute}.jpg)">

Now the problem is to put an "if" for choosing texture or color hex when needed, something like:

{foreach from=$product.colors key=id_attribute item=color}
      {IF "IS A TEXTURE"}
		 <span class="color_picker" style="background: url(/img/co/{$id_attribute}.jpg)" title="{$color.name}"></span>
      {ELSE}
                 <span class="color_picker" style="background: {$color.value};" title="{$color.name}"></span>
         {/IF}
    {/foreach}

Any clue ?

Thanks

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

  • 2 weeks later...

Hey all,

 

Great work everyone on this, I'm trying to get it working on my theme "parfijure" and seem to be running into some problems.

 

I've completed these steps:

1. blocklayered.php
added relevant code under here:
 

$products = Product::getProductsProperties((int)$cookie->id_lang, $products); 

3. product_list.css
added this code to the css

#product_list li .color_picker span {
border: 1px solid #F8F8F8;
display: inline-block;
height: 14px;
width: 8px;x;
}

However I'm having issues adding the below to product-list.tpl

<!-- START color picker -->
<div class="color_picker">
{if isset($product.colors)}{foreach from=$product.colors item=v}
<span style="background: {$v.value};" title="{$v.name}"></span>{/foreach}
{/if}
</div>
<!-- END color picker -->

My theme doesn't appear to have a div class="center_block" tag

I have tried putting it in multiple places with no luck, I did think this might be the best fit.

<div class="product-shop">

My Product-list.tpl looks like this:

{if isset($products)}
    <!-- Products list -->
    <div id="products_wrapper">
        <ul class="products-grid columns3" id="grid_view_product">
            {foreach from=$products item=product name=products}
                <li  class="ajax_block_product {if $smarty.foreach.products.first}first{elseif $smarty.foreach.products.last}last{/if} {if $smarty.foreach.products.index % 2} {else}{/if} item last">
                {if isset($product.new) && $product.new == 1}<div class="newproduct_label">{l s='New'}</div>{/if}
                {if isset($product.on_sale) && $product.on_sale && isset($product.show_price) && $product.show_price && !$PS_CATALOG_MODE} <div class="saleproduct_label">{l s='Sale'}</div>{/if}
                 <div class="box-product-item">
                                        <div class="box-product-buttons">
										                                           <input type="hidden" name="qty" id="quantity_wanted" class="text"  value="1" size="2" maxlength="3" />
                                            <div class="buttons-compare link-compare"  id="comparator_item_{$product.id_product}" ></div>
                                            <div class="buttons-wish" onclick="WishlistCart('wishlist_block_list', 'add', '{$product.id_product|intval}', $('#idCombination').val(), document.getElementById('quantity_wanted').value); return false;"></div>    
                                        </div>
                                        <div class="box-line"></div>
                                        <div class="view-first">
                                            <div class="view-content">
                                                <div class="image">
                                                    <a href="{$product.link}" title="{$product.name|escape:html:'UTF-8'}" class="product_img_link">
                                                        <img src="{$link->getImageLink($product.link_rewrite, $product.id_image, 'home_default')}"  alt="{$product.name|escape:html:'UTF-8'}" />
                                                    </a>
                                                </div>
                                                <div class="name">
                                                    <a href="{$product.link}" title="{$product.name|truncate:50:'...'|escape:'htmlall':'UTF-8'}">{$product.name|truncate:35:'...'|escape:'htmlall':'UTF-8'}</a>
                                                </div>
                                                <div class="price clearfix">
                                                    <div class="price-box">
                                                        {if ((isset($product.on_sale) && $product.on_sale) || (isset($product.reduction) && $product.reduction)) && $product.price_without_reduction > $product.price && $product.show_price AND !isset($restricted_country_mode) && !$PS_CATALOG_MODE}
                                                            <p class="old-price">
                                                                <span class='price'>
                                                                {convertPrice price=$product.price_without_reduction}
                                                                </span>
                                                            </p>{else}     
                                                        {/if}
                                                  <p class="special-price"> 
                                                    {if $product.show_price AND !isset($restricted_country_mode) AND !$PS_CATALOG_MODE}  {if !$priceDisplay}<span class="price">{convertPrice price=$product.price}</span>{else}<span class="price">{convertPrice price=$product.price_tax_exc}</span>{/if}{else}<div style="height:21px;"></div>{/if}
                                                </p>

                                    </div>
                                </div>
                                {if ($product.id_product_attribute == 0 OR (isset($add_prod_display) AND ($add_prod_display == 1))) AND $product.available_for_order AND !isset($restricted_country_mode) AND $product.minimal_quantity == 1 AND $product.customizable != 2 AND !$PS_CATALOG_MODE}
                                    {if ($product.quantity > 0 OR $product.allow_oosp)}
                                        <div class="exclusive ajax_add_to_cart_button buttons-cart" rel="ajax_id_product_{$product.id_product}" href="{$link->getPageLink('cart')}?qty=1&id_product={$product.id_product}&token={$static_token}&add" title="{l s='Add to cart' mod='homefeatured'}">{l s='Add to cart'}</div> 
                                    {else}
                                        <div class="buttons-cart">{l s='Out Of Stock'}</div>
                                    {/if}
                                {/if}
                                <div class="box-product-buttons">
                                    <input type="hidden" name="qty" id="quantity_wanted" class="text"  value="1" size="2" maxlength="3" />   
                                    <a  class="buttons-compare link-compare"  id="comparator_item_{$product.id_product}">+{l s='Compare'}</a>
                                    <a onclick="WishlistCart('wishlist_block_list', 'add', '{$product.id_product|intval}', $('#idCombination').val(), document.getElementById('quantity_wanted').value); return false;" class="buttons-wish">+ {l s='Wishlist'}</a>
                                </div>
							                            </div>
                        </div>
                    </div>
         

        </li>

        {/foreach}           
        </ul>
        <ol class="products-list" id="products-list">
                {foreach from=$products item=product name=products}
                    <li  class="ajax_block_product {if $smarty.foreach.products.first}first{elseif $smarty.foreach.products.last}last{/if} {if $smarty.foreach.products.index % 2} {else}{/if} item ">
                    {if isset($product.on_sale) && $product.on_sale && isset($product.show_price) && $product.show_price && !$PS_CATALOG_MODE} <div class="saleproduct_label">{l s='Sale' }</div>{/if}
                {if isset($product.new) && $product.new == 1}<div class="newproduct_label">{l s='New' }</div>{/if}

                <a href="{$product.link}" title="{$product.name|escape:html:'UTF-8'}" class="product_img_link product-image" id="productimgover22">
                    <img  class="fade-image" src="{$link->getImageLink($product.link_rewrite, $product.id_image, 'home_default')}"  alt="{$product.name|escape:html:'UTF-8'}" />
                </a>
                <div class="product-shop">
                    <div class="f-fix">
                        <h2 class="product-name">
                            <a href="{$product.link}" title="{$product.name|truncate:50:'...'|escape:'htmlall':'UTF-8'}">{$product.name|truncate:35:'...'|escape:'htmlall':'UTF-8'}</a>
                        </h2>
                        <div id="productimgover1" style="display: none;">
                            <img   src="{$link->getImageLink($product.link_rewrite, $product.id_image, 'home_default')}"  alt="{$product.name|escape:html:'UTF-8'}" />
                        </div>
                        <div id='productname1' style='display:none'>{$product.name|truncate:50:'...'|escape:'htmlall':'UTF-8'}</div>
                        <div class="desc std">
                            {$product.description_short|strip_tags:'UTF-8'|truncate:360:'...'}                    
                            <a href="{$product.link}" title="{$product.name|escape:html:'UTF-8'}" class="link-learn">{l s='Learn'}More</a>
                        </div>
                    </div>
                    <div style="clear: both;"></div>
                </div>
                <div class="addtocont">
                    <div class="price-box">
                {if $product.show_price AND !isset($restricted_country_mode) AND !$PS_CATALOG_MODE}  <p class="special-price"> <span class="price-label">{l s='Regular Price:' mod='homefeatured'}</span> <span class="price" id="product-price">{if !$priceDisplay}{convertPrice price=$product.price}{else}{convertPrice price=$product.price_tax_exc}{/if}</span></p>{else}<div style="height:21px;"></div>{/if}

                </div>
				                <a href="{$product.link|escape:'htmlall':'UTF-8'}" style="display:none;"  title="{$product.name|escape:'htmlall':'UTF-8'}" class="product-image product_img_link">
                <img src="{$link->getImageLink($product.link_rewrite, $product.id_image, 'home_default')}" alt="{$product.legend|escape:'htmlall':'UTF-8'}" width="135" alt="{$product.name|escape:'htmlall':'UTF-8'}" />
                </a>
                <p>
                {if ($product.id_product_attribute == 0 || (isset($add_prod_display) && ($add_prod_display == 1))) && $product.available_for_order && !isset($restricted_country_mode) && $product.minimal_quantity <= 1 && $product.customizable != 2 && !$PS_CATALOG_MODE}
                {if ($product.allow_oosp || $product.quantity > 0)}
                    {if isset($static_token)}
                        <button rel="ajax_id_product_{$product.id_product|intval}" title="{l s='Add to cart'}" class="ajax_add_to_cart_button button btn-cart" onclik="{$link->getPageLink('cart',false, NULL, "add&id_product={$product.id_product|intval}&token={$static_token}", false)}"><span><span>{l s='Add to cart'}</span></span></button>					
                    {else}
                        <button rel="ajax_id_product_{$product.id_product|intval}" title="{l s='Add to cart'}" class="ajax_add_to_cart_button button btn-cart" onclik="{$link->getPageLink('cart',false, NULL, "add&id_product={$product.id_product|intval}&token={$static_token}", false)}"><span><span>{l s='Add to cart'}</span></span></button>
                    {/if}						
                {else}
                    <button title="{l s='Out of stock'}" class="ajax_add_to_cart_button button btn-cart" ><span><span>{l s='Out of Stock'}</span></span></button>
                {/if}
                {/if} 
                </p>
                <div class="box-product-buttons">
                    <input type="hidden" name="qty" id="quantity_wanted" class="text"  value="1" size="2" maxlength="3" />   
                    <a  class="buttons-compare link-compare"  id="comparator_item_{$product.id_product}">+{l s='Compare'}</a>
                    <a onclick="WishlistCart('wishlist_block_list', 'add', '{$product.id_product|intval}', $('#idCombination').val(), document.getElementById('quantity_wanted').value); return false;" class="buttons-wish">+ {l s='Wishlist'}</a>
                </div>

                </div>
                </li>
                {/foreach}
        </ol>
     </div>
<!-- /Products list -->
{/if}

Any fingers in  the right direction would be amazing.

 

cheers

Link to comment
Share on other sites

Try insert the code after:

<div class="image">

so it would be:

<div class="image">
<div class="color_picker">
{if isset($product.colors)}{foreach from=$product.colors item=v}
<span style="background: {$v.value};" title="{$v.name}"></span>{/foreach}
{/if}
</div>

Link to comment
Share on other sites

I solved changing product-list.tpl file:

<span class="color_picker" style="background: {$color.value};" title="{$color.name}"></span>

in:

<span class="color_picker" style="background: url(/img/co/{$id_attribute}.jpg)">

Now the problem is to put an "if" for choosing texture or color hex when needed, something like:

{foreach from=$product.colors key=id_attribute item=color}
      {IF "IS A TEXTURE"}
		 <span class="color_picker" style="background: url(/img/co/{$id_attribute}.jpg)" title="{$color.name}"></span>
      {ELSE}
                 <span class="color_picker" style="background: {$color.value};" title="{$color.name}"></span>
         {/IF}
    {/foreach}

Any clue ?

Thanks

 

Well, function "if" is now unnecessary. Just add every color you need in jpg and that's will be ok.

Link to comment
Share on other sites

  • 1 month later...
  • 2 weeks later...

Hi Guys
My name is Daria, I'm the owner of the online store www.dressmylegs.ie. I have a similar problem with displaying product colours on certain sections on the website (it's PS 1.5.4.) which was never a problem on the old website.

 

My web developer says it's impossible to do this in PS1.5 with the Leo Dress theme but he'd told me things were impossible before and I managed to find a solution in the forum, so I would appreciate any help.

 

All product colours are currently displayed as squares under each product photo in product listing. However, in certain circumstances they are not visible, e.g. in:
- New Styles
- Best Sellers
- Special Offers
- when any of the filters on the left are used
- when you access the products from BRANDS on the top menu.
The colour squares are displayed fine if you simply choose a category from the top menu, but not in the scenarios above. Do you think there is a solution for this?
Thank you in advance.
 

Link to comment
Share on other sites

The colors show up correctly, but the custom texture not show :(  Somebody have solution for this problem?  
I think, the problem  in this part of code: 


if ((isset($row['attribute_color']) && $row['attribute_color']) || (file_exists(_PS_COL_IMG_DIR_.$row['id_attribute'].'.jpg')))

{
$colors[$row['id_attribute']]['value'] = $row['attribute_color'];
$colors[$row['id_attribute']]['name'] = $row['attribute_name'];
}
Sobebody help please! 
Edited by websprint (see edit history)
Link to comment
Share on other sites

  • 1 month later...

For some reason i cannot get this to work in 1.4.7.3 (and i don't use layered navigation).

No effects here :(

Has someone succeeded with this in 1.4.7.3 ?

 

I have color picker enabled on product page, but i'd like to have it on product list as well (it doesn't necessarilly have to open another pic, it just should indicate /by color squares/ how many different colors are available).

 

 

Thanks

And how do if color is used instead of a picture? For example, there:(

I solved changing product-list.tpl file:
<span class="color_picker" style="background: {$color.value};" title="{$color.name}"></span>
in:
<span class="color_picker" style="background: url(/img/co/{$id_attribute}.jpg)">
Now the problem is to put an "if" for choosing texture or color hex when needed, something like:
{foreach from=$product.colors key=id_attribute item=color}
      {IF "IS A TEXTURE"}
		 <span class="color_picker" style="background: url(/img/co/{$id_attribute}.jpg)" title="{$color.name}"></span>
      {ELSE}
                 <span class="color_picker" style="background: {$color.value};" title="{$color.name}"></span>
         {/IF}
    {/foreach}
Any clue ?
Thanks

Oh, thx!)) I missed this post )

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

  • 1 month later...
  • 2 months later...

Prestashop 1.4 SearchController.php - just change all the if()

if ($this->instantSearch && !is_array($query))
  {
   $this->productSort();
   $this->n = abs((int)(Tools::getValue('n', Configuration::get('PS_PRODUCTS_PER_PAGE'))));
   $this->p = abs((int)(Tools::getValue('p', 1)));
   $search = Search::find((int)(self::$cookie->id_lang), $query, $this->p, $this->n, $this->orderBy, $this->orderWay);
   Module::hookExec('search', array('expr' => $query, 'total' => $search['total']));
   $nbProducts = $search['total'];
   $this->pagination($nbProducts);
  
  
    //[email protected]
  
    $this->pesquisa =$search['result'];
	 foreach ( $this->pesquisa as $key => $pesquisa ) {
	  $product = new Product ( intval ( $pesquisa[ 'id_product' ] ), true , intval ( self::$cookie -> id_lang ));
	  $colors = array();
	  $attributesGroups = $product->getAttributesGroups((int)(self::$cookie->id_lang));
	  if ( Db :: getInstance ()-> numRows ()) {
	 foreach ( $attributesGroups AS $k => $row ) {
	   if (isset( $row[ 'attribute_color' ] ) AND $row[ 'attribute_color' ] AND $row[ 'id_attribute_group' ] == $product -> id_color_default ){
	    $colors[$row[ 'id_attribute' ]][ 'value' ] = $row[ 'attribute_color' ] ;
	    $colors[$row[ 'id_attribute' ]][ 'name' ] = $row[ 'attribute_name' ] ;
	    $colors[$row[ 'id_attribute' ]][ 'id' ] = $row[ 'id_attribute' ] ;
	   }
	  }
	 }
	  $this->pesquisa[$key][ 'colors' ] = $colors ;
	 }
   //
  
  
   self::$smarty->assign(array(
   'products' => $search['result'], // DEPRECATED (since to 1.4), not use this: conflict with block_cart module
   'search_products' => $this->pesquisa,
   'nbProducts' => $search['total'],
   'search_query' => $query,
   'instantSearch' => $this->instantSearch,
   'homeSize' => Image::getSize('home')));
  }
and

 

another if ()

 

elseif ($query = Tools::getValue('search_query', Tools::getValue('ref')) AND !is_array($query))
  {
   $this->productSort();
   $this->n = abs((int)(Tools::getValue('n', Configuration::get('PS_PRODUCTS_PER_PAGE'))));
   $this->p = abs((int)(Tools::getValue('p', 1)));
   $search = Search::find((int)(self::$cookie->id_lang), $query, $this->p, $this->n, $this->orderBy, $this->orderWay);
  
  
  
  
   Module::hookExec('search', array('expr' => $query, 'total' => $search['total']));
   $nbProducts = $search['total'];
   $this->pagination($nbProducts);
  
  
    //[email protected]
  
    $this->pesquisa =$search['result'];
	 foreach ( $this->pesquisa as $key => $pesquisa ) {
	  $product = new Product ( intval ( $pesquisa[ 'id_product' ] ), true , intval ( self::$cookie -> id_lang ));
	  $colors = array();
	  $attributesGroups = $product->getAttributesGroups((int)(self::$cookie->id_lang));
	  if ( Db :: getInstance ()-> numRows ()) {
	 foreach ( $attributesGroups AS $k => $row ) {
	   if (isset( $row[ 'attribute_color' ] ) AND $row[ 'attribute_color' ] AND $row[ 'id_attribute_group' ] == $product -> id_color_default ){
	    $colors[$row[ 'id_attribute' ]][ 'value' ] = $row[ 'attribute_color' ] ;
	    $colors[$row[ 'id_attribute' ]][ 'name' ] = $row[ 'attribute_name' ] ;
	    $colors[$row[ 'id_attribute' ]][ 'id' ] = $row[ 'id_attribute' ] ;
	   }
	  }
	 }
	  $this->pesquisa[$key][ 'colors' ] = $colors ;
	 }
  
  
  
  
   self::$smarty->assign(array(
   'products' => $search['result'], // DEPRECATED (since to 1.4), not use this: conflict with block_cart module
   'search_products' => $this->pesquisa,
   'nbProducts' => $search['total'],
   'search_query' => $query,
   'homeSize' => Image::getSize('home')));
  }
and if you use cloud tags module

 

elseif ($tag = urldecode(Tools::getValue('tag')) AND !is_array($tag))
  {
   $nbProducts = (int)(Search::searchTag((int)(self::$cookie->id_lang), $tag, true));
   $this->pagination($nbProducts);
   $result = Search::searchTag((int)(self::$cookie->id_lang), $tag, false, $this->p, $this->n, $this->orderBy, $this->orderWay);
  
  
   //[email protected]
  
    $this->pesquisa =$result;
	 foreach ( $this->pesquisa as $key => $pesquisa ) {
	  $product = new Product ( intval ( $pesquisa[ 'id_product' ] ), true , intval ( self::$cookie -> id_lang ));
	  $colors = array();
	  $attributesGroups = $product->getAttributesGroups((int)(self::$cookie->id_lang));
	  if ( Db :: getInstance ()-> numRows ()) {
	 foreach ( $attributesGroups AS $k => $row ) {
	   if (isset( $row[ 'attribute_color' ] ) AND $row[ 'attribute_color' ] AND $row[ 'id_attribute_group' ] == $product -> id_color_default ){
	    $colors[$row[ 'id_attribute' ]][ 'value' ] = $row[ 'attribute_color' ] ;
	    $colors[$row[ 'id_attribute' ]][ 'name' ] = $row[ 'attribute_name' ] ;
	    $colors[$row[ 'id_attribute' ]][ 'id' ] = $row[ 'id_attribute' ] ;
	   }
	  }
	 }
	  $this->pesquisa[$key][ 'colors' ] = $colors ;
	 }
  
  
  
   //
  
  
   Module::hookExec('search', array('expr' => $tag, 'total' => sizeof($result)));
   self::$smarty->assign(array(
   'search_tag' => $tag,
   'products' => $this->pesquisa, // DEPRECATED (since to 1.4), not use this: conflict with block_cart module
   'search_products' => $this->pesquisa,
   'nbProducts' => $nbProducts,
   'homeSize' => Image::getSize('home')));
  }

What about Prestashop 1.5 . Can sombody have solution ? PLEASE!

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

  • 1 month later...

hello

 

i have a problem on product-list.tpl

 

the code of product-list.tpl is

 

<ul class="color_to_pick_list clearfix">
    {foreach from=$colors_list item='color'}
        <li>
            <a href="{$link->getProductLink($color.id_product, null, null, null, null, null, $color.id_product_attribute)|escape:'html':'UTF-8'}" id="color_{$color.id_product_attribute|intval}" class="color_pick" style="background:{$color.color}"></a>
        </li>
    {/foreach}
</ul>

 

but i want to insert this code

 

{if $color.color == #000000}

<li>
   <a href="{$link->getProductLink($color.id_product, null, null, null, null, null, $color.id_product_attribute)|escape:'html':'UTF-8'}" id="color_{$color.id_product_attribute|intval}" class="color_pick" style="background:-moz-linear-gradient(left,red,lime,blue);"></a>

</li>

{else}

<li>
   <a href="{$link->getProductLink($color.id_product, null, null, null, null, null, $color.id_product_attribute)|escape:'html':'UTF-8'}" id="color_{$color.id_product_attribute|intval}" class="color_pick" style="background:{$color.color}"></a>

</li>

{/if}

 

but is not fine, and i can't understand ....

Link to comment
Share on other sites

  • 4 months later...
  • 6 months later...
  • 2 months later...
  • 6 months later...

Olá.

Para quem esteja passando por problemas, Eu produzi rapidamente um módulo que busca as cores dos produtos dentro da home(homefeatured) ou outra área que contenha informações de produto.

Estou deixando em anexo, para usa-lo basta instalar normalmente e colar o hook: "{hook h='displayColorList' product=$product}" na área desejada. Eu recomendo o arquivo product-list.tpl antes da linha "<div class="right-block">" ou homefeatured.tpl (módulo).

Testado para versão 1.6.x.

Sintam-se a vontade para baixar e alterar.

Até mais.

________________________________

Hello.

For those who experience problems, I quickly produce a module that fetches the colors of the products within the home (homefeatured) or other area containing product information.

I'm leaving in the annex, to use it just install normally and paste the hook: "{h = hook 'displayColorList' product = $product}" in the desired area. I recommend the product-list.tpl file before the line "<div class =" right-block ">" or homefeatured.tpl (module).

Tested to version 1.6.x.

Feel the will to download and change.

See you.

blockcolorpicker.zip

Edited by Pedro Henrique (see edit history)
  • Like 1
Link to comment
Share on other sites

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