Jump to content

Available product sizes on product list[Solved]


ruslan1984

Recommended Posts

Guys, I have tried the solutions provided on the forum to achieve this, but nothing works. I either get the blank screen or blank screen:)

I want to show available sizes of clothes right under the product images on the product list. 

I'm using default theme, version 1.5.6.1. However I have modified product list tpl and css file for the grid view. My domain is sweet5.kg

 

Can anybody help me with the code? I quite stranger to the php and smarty:)

 

Thank you in advance. 

Regards, 

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

Hello,

 

If available sizes are features you can :

- activate smarty debug and then look if needed features are send when you watch product list

- look at product tpl to see code example that deals with features

 

If you are lucky enough you will only have to modify product-list.tpl

 

Regards

Link to comment
Share on other sites

it will not be as easy as it seems, but it's possible.

i can do it step by step with you.

for the first please create new hook, call it, for exaple displayProductOnList
and insert {Hook::exec('displayProductOnList')} to the product-list.tpl file

for example, right below the:

				{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)}
							<a class="button ajax_add_to_cart_button exclusive" rel="ajax_id_product_{$product.id_product|intval}" href="{$link->getPageLink('cart',false, NULL, "add=1&id_product={$product.id_product|intval}&token={$static_token}", false)|escape:'html'}" title="{l s='Add to cart'}"><span></span>{l s='Add to cart'}</a>
						{else}
							<a class="button ajax_add_to_cart_button exclusive" rel="ajax_id_product_{$product.id_product|intval}" href="{$link->getPageLink('cart',false, NULL, "add=1&id_product={$product.id_product|intval}", false)|escape:'html'}" title="{l s='Add to cart'}"><span></span>{l s='Add to cart'}</a>
						{/if}						
					{else}
						<span class="exclusive"><span></span>{l s='Add to cart'}</span><br />
					{/if}
				{/if}
{Hook::exec('displayProductOnList')} 

if it will be ready, let me know :)

Link to comment
Share on other sites

Ok, I renamed the hook and installed the module. 

Cleared the cache and the available sizes appeared :)

 

I gave it a try and I really like it, however I have a problem. If the product is sold out and not available, the item still shows the sizes it had when was originally posted. And if one size of a product is also sold it is not removed from the list of available sizes it is displayed.

 

How can this be fixed.  

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

  • 1 month later...

Top notch solution vekia!
 

But how to separate attributes?

Size: M, L, XL, XXL

Color: Red, Blue, Green

 

because now we have something like this (combination of 9 colors and 3 sizes) a little bit messy! :D

 

Color: Blue | Size: XS | Color: Pink | Size: XS | Color: Green | Size: XS | Color: Orange | Size: XS | Color: Black | Size: XS | Color: Purple | Size: XS | Color: Yellow | Size: XS | Color: Red | Size: XS | Color: Blue | Size: S | Color: Pink | Size: S | Color: Green | Size: S | Color: Orange | Size: S | Color: Black | Size: S | Color: Purple | Size: S | Color: Yellow | Size: S | Color: Red | Size: S | Color: Blue | Size: M | Color: Pink | Size: M | Color: Green | Size: M | Color: Orange | Size: M | Color: Black | Size: M | Color: Purple | Size: M | Color: Yellow | Size: M | Color: Red | Size: M |

 

or how to view only one attribute Size (without Colors)?

 

Thanks!

Edited by kisweb (see edit history)
  • Like 2
Link to comment
Share on other sites

you can create if condtions in tpl file to display only sizes.

i dont remember array structure

but you can use |print_r on variable with attribute, then you will see probably something like attribute_group (as far as i remember)

 

then create if condition like

 

{if $variable.attribute_group==2}

   {$variable}

{/if}

Link to comment
Share on other sites

  • 5 weeks later...

you can create if condtions in tpl file to display only sizes.

i dont remember array structure

but you can use |print_r on variable with attribute, then you will see probably something like attribute_group (as far as i remember)

 

then create if condition like

 

{if $variable.attribute_group==2}

   {$variable}

{/if}

 

 

Vekia help me please

 

This is the way ¿?, no works me

{if $combinations.group.name=="Size"}More sizes{/if}
Link to comment
Share on other sites

{foreach $combinations as $k=>$v}

{if $v.quantity>0}

<strong> {$v.group_name}:</strong>

{$v.attribute_name} |

{/if}

{/foreach}

 

 

I try it also with and no works

 

{if $v.group_name=='Size'}More sizes{/if}

 

I just want that when a product has a certain attribute display a message

 

Very thanks

Link to comment
Share on other sites

  • 2 weeks later...
  • 2 months later...
  • 2 weeks later...
  • 3 weeks later...

Hi

Regarding this module, is there a way of displaying "Size" in front of the available sizes? I've modified the tpl file as below:

 

<div class="combos">{foreach $combinations as $k=>$v}

{if $v.quantity>0}

{$v.attribute_name},

{/if}

{/foreach}</div>

 

This shows the available sizes. I'd like to have it to show "Sizes: Small, Medium". So far, if I put the "size" text in the foreach command the word sizes obviously shows for every size. If i place the "size" text outside it, the text shows up even for items which have no sizes.

 

 

Also, would there be a way of translating the attributes? For instance, my attributes are called "Small, Medium, etc...", but I'd like them displayed on the product list as "S, M, etc...", while keeping the longer attribute names for the actual product page.

 

Any help appreciated!!

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

  • 2 weeks later...

Hi Vekia, can you please give a little advice for Prestashop 1.6.

How can I create a hook here? I can only choose a modul and then Hoot it in some region.

Help please if u have time!

 

Hello Maxim_z

You dont need to create any hook or move module to other place via change module positions.

Just add

{Hook::exec('displayProductOnList', $product)}

in product-list.tpl file located in Your template folder themes/default-bootstrap/product-list.tpl and product attribute will be available in homepage featured products and product in categories without any hassle.

 

Let me know if this help

  • Like 1
Link to comment
Share on other sites

Is it possible to have translations for the sizes? For example, My sizes appear on the product pages as "UK 3, UK 4" etc... But I'd like them to show on the product list page as 3, 4, 5, etc, as it looks less cluttered, especially for clothing sizes (i.e. "S, M, L" instead of "Small, Medium, Large").

Link to comment
Share on other sites

  • 2 weeks later...

Hi! Cześć!

Please open template product-list.tpl file and replace

{Hook::exec('displayProductOnList', $product)}

to

<span style="color:#666;font-size:11px;">{l s='Available sizes'}: {Hook::exec('displayProductOnList', $product)}</span>

And in modules/attributes/ edit combinations.tpl

and replace to:

{foreach $combinations as $k=>$v}
{$v.attribute_name} <- put here one blank space but , or | separator will be better imho
{/foreach}
Edited by PrestaShark (see edit history)
Link to comment
Share on other sites

Is it possible to have translations for the sizes? For example, My sizes appear on the product pages as "UK 3, UK 4" etc... But I'd like them to show on the product list page as 3, 4, 5, etc, as it looks less cluttered, especially for clothing sizes (i.e. "S, M, L" instead of "Small, Medium, Large"). 

Link to comment
Share on other sites

  • 2 weeks later...

you can create if condtions in tpl file to display only sizes.

i dont remember array structure

but you can use |print_r on variable with attribute, then you will see probably something like attribute_group (as far as i remember)

 

then create if condition like

 

{if $variable.attribute_group==2}

   {$variable}

{/if}

 

First, thanks a lot for this module :)

 

I'd like to display it differently but I need some more options...

 

I'd like to display it like this:

 

Size: XXX

Color: XXX

 

but how can I find the attribute group ?

 

.attribute_group, .group_type don't work...

 

Could you help me please ?

 

Thanks

Link to comment
Share on other sites

  • 2 months later...

Hello everyone,

I tried this in ps 1.5.4.1 including the hook and then installed the module and also emptied cachec but there are no attributes appearing in product list.

Does anyone use similar version that works. I dont suppose i am the only to whom it doesnt work.

Any ideas what i could be doing wrong?

Thank you

Link to comment
Share on other sites

Hi all,

 

i editing Vekia Module combination.tpl with this code:

{foreach $combinations as $k=>$v}
{if $v.id_attribute_group==1}
   {$v.attribute_name} |
{/if}
{/foreach}

but with this code i have this situation:

 

1 | 1 | 1 | 2 | 2 | 2 | 3 | 3 | 3 | 4 | 4 | 4

because i have for esample 3 color: 1/skin 1/black 1/white 2/skin 2/black 2/white.... etc...

how to modify this code so that it can give only one attribute? example: 1 | 2 | 3

thank you all for the help

Link to comment
Share on other sites

Dont know about efficiency of code but it works fine for me. :P  :)

 

 

Modify combination.tpl as:

 

{$sizes = array()}

{$i = 0}

{foreach $combinations as $k=>$v}

    {if $v.quantity > 0 && $v.id_attribute_group == 1}    

        {$sizes[$i] = $v.attribute_name}

        {$i = $i+1}

    {/if}

{/foreach}

 

{$sizes = array_unique($sizes)}

{if $i > 0}

<div class="size-area">

    <span>Sizes: </span>

{foreach $sizes as $a}

        <p>{$a}</p>

{/foreach}

</div>

{/if}

Link to comment
Share on other sites

  • 3 weeks later...

Hi guys!

 

Uncle google told me that i can find solution for my problem in this topic.

 

What i want to archieve, is to show available colours of my products in my clothes store. 

 

First i tried to seperate product attributes (colours) as individual products, but i have  found it very hard to make and there is big risk of messing with the code ( it was sth about deleting product ID)

 

Then i found the solution presented in this topic and I also face problems which ruslan1984 and prestashark in post #19 did.

 

Unfortunately i have no idea how to implement it in my store and i'm looking for a person who could do this for cash.

 

I'm also interested in starting multistore , my PS version is 1.5.6.2 

 

PLZ contact me with price offers

 

PS. I speak both polish and english in case. 

 

[email protected]

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

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

Hi,

I know that topic is solved, but I have problem related to it, and I can't make it work. My prestashop version is 1.6.0.14, and I created a hook in my database - I checked it exist. 

I already add attributes module from Vekia and paste a hook:

{if (!$PS_CATALOG_MODE AND ((isset($product.show_price) && $product.show_price) || (isset($product.available_for_order) && $product.available_for_order)))}
					<div class="content_price">
						{if isset($product.show_price) && $product.show_price && !isset($restricted_country_mode)}
							<span class="price product-price">
								{if !$priceDisplay}{convertPrice price=$product.price}{else}{convertPrice price=$product.price_tax_exc}{/if}
							</span>
							{if isset($product.specific_prices) && $product.specific_prices && isset($product.specific_prices.reduction) && $product.specific_prices.reduction > 0}
								{hook h="displayProductPriceBlock" product=$product type="old_price"}
								<span class="old-price product-price">
									{displayWtPrice p=$product.price_without_reduction}
								</span>
								{hook h="displayProductPriceBlock" id_product=$product.id_product type="old_price"}
							{/if}
							{hook h="displayProductPriceBlock" product=$product type="price"}
							{hook h="displayProductPriceBlock" product=$product type="unit_price"}
                                                        {hook h="displayProductOnList" product=$product} 

in product-list.tpl file... but it don't work

My shop: http://nikboutique.com/12-mezczyzna

I want in my product grid on hover appear avilable sizes above the price. 

 

Thanks in advance for any help!!!

Adriana

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

  • 5 months later...

Hello and happy new Year,

 

this modul is very interesting. i have modified the the combination.tpl for output the default combination as excample:
 

{foreach $combinations as $k=>$v}
{if $v.default_on==1}
	<strong>{$v.group_name}:</strong> {$v.attribute_name}
{/if}
{/foreach}

But such as i can change $v.group_name to the puplic_name?

 

this is not work: $v.group_public_name
my ps version is 1.6.1.3

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

There's plenty topics about it, meaning PS users need it very much - clients need it too for easier moving on the page and for a better look on the page without duplicating same product with just different size or color.

 

I have found also this topic: https://www.prestashop.com/forums/topic/279551-how-to-show-product-attribute-option-in-product-list/ still no full solution, but it is good to try and modify something and share...

Link to comment
Share on other sites

  • 4 weeks later...

Hello there! I tried Vieka's solution and it's works, I made the attributes like a drop down menu so the customer can choose what's attribute they want to order,however, after hitting the "Add to cart" button, it didn't display the attribute I've chose. It displays the default attribute and not what I've chosen. Please help!

Link to comment
Share on other sites

  • 1 month later...

Hi,

I know that topic is solved, but I have problem related to it, and I can't make it work. My prestashop version is 1.6.0.14, and I created a hook in my database - I checked it exist. 

I already add attributes module from Vekia and paste a hook:

{if (!$PS_CATALOG_MODE AND ((isset($product.show_price) && $product.show_price) || (isset($product.available_for_order) && $product.available_for_order)))}
					<div class="content_price">
						{if isset($product.show_price) && $product.show_price && !isset($restricted_country_mode)}
							<span class="price product-price">
								{if !$priceDisplay}{convertPrice price=$product.price}{else}{convertPrice price=$product.price_tax_exc}{/if}
							</span>
							{if isset($product.specific_prices) && $product.specific_prices && isset($product.specific_prices.reduction) && $product.specific_prices.reduction > 0}
								{hook h="displayProductPriceBlock" product=$product type="old_price"}
								<span class="old-price product-price">
									{displayWtPrice p=$product.price_without_reduction}
								</span>
								{hook h="displayProductPriceBlock" id_product=$product.id_product type="old_price"}
							{/if}
							{hook h="displayProductPriceBlock" product=$product type="price"}
							{hook h="displayProductPriceBlock" product=$product type="unit_price"}
                                                        {hook h="displayProductOnList" product=$product} 

in product-list.tpl file... but it don't work

My shop: http://nikboutique.com/12-mezczyzna

I want in my product grid on hover appear avilable sizes above the price. 

 

Thanks in advance for any help!!!

Adriana

Hi,

 

I visited your site, and likes the way you display sizes on hover.

 

How did you manage to do it ?

 

Thanks to everyone for sharing helps !!

 

Thanks

Link to comment
Share on other sites

it will not be as easy as it seems, but it's possible.

i can do it step by step with you.

for the first please create new hook, call it, for exaple displayProductOnList

and insert {Hook::exec('displayProductOnList')} to the product-list.tpl file

 

for example, right below the:

				{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)}
							<a class="button ajax_add_to_cart_button exclusive" rel="ajax_id_product_{$product.id_product|intval}" href="{$link->getPageLink('cart',false, NULL, "add=1&id_product={$product.id_product|intval}&token={$static_token}", false)|escape:'html'}" title="{l s='Add to cart'}"><span></span>{l s='Add to cart'}</a>
						{else}
							<a class="button ajax_add_to_cart_button exclusive" rel="ajax_id_product_{$product.id_product|intval}" href="{$link->getPageLink('cart',false, NULL, "add=1&id_product={$product.id_product|intval}", false)|escape:'html'}" title="{l s='Add to cart'}"><span></span>{l s='Add to cart'}</a>
						{/if}						
					{else}
						<span class="exclusive"><span></span>{l s='Add to cart'}</span><br />
					{/if}
				{/if}
{Hook::exec('displayProductOnList')} 

if it will be ready, let me know :)

Hi ,

I'm new on prestashop I have found your solution while searching on the net, what I want to do is to show the size on product listing but I don't know how to do this : 

create new hook, call it, for exaple displayProductOnList.Can you help me please

Link to comment
Share on other sites

  • 1 month later...

Hello! Veka, did you make an updated version of the module? I have been trying (and failed) to implement this as well couple times... Would be very helpful for displaying product attributes on the product-list. 

Link to comment
Share on other sites

1.6.1.4 ! 

To be clear I haven't installed your module, having read the entire topic and saw that you where preparing a "non-beta" version. 
So far I tried to modify the code in the product-list.tpl by taking the same code as in the product.tpl in order to call the variables for attributes. I have to admit not being an expert in development and seing all the discussion here I was a bit confused about the outcome of the subject...

Link to comment
Share on other sites

  • 2 weeks later...

Coming back here :-) I realize I wasn't clear enough actually.

So yes, the module works just fine. But it only displays the available features. 

 

--> Is there a way of, basically, being able to select the feature you want on the product-list, to avoid going on the product page? 

Basically, I would like the right-column of the product list to be the same as the right column of the product-page --> so no need to click on a product in order to buy it with the feature you want. 

Link to comment
Share on other sites

  • 2 weeks later...

Coming back here :-) I realize I wasn't clear enough actually.

So yes, the module works just fine. But it only displays the available features. 

 

--> Is there a way of, basically, being able to select the feature you want on the product-list, to avoid going on the product page? 

Basically, I would like the right-column of the product list to be the same as the right column of the product-page --> so no need to click on a product in order to buy it with the feature you want. 

 

with this free modification it is not possible. It requires custom development.

Hello we're looking for the same way on PS 1.6.0.5

 

this is free module that i no longer develop doesnt have this feature. if you want such feature it requires custom development

Link to comment
Share on other sites

  • 2 weeks later...
  • 4 months later...

hello

I use variable {$v.attribute_name} in the combinations.tpl and it shown me all available combinations, but i want to make another line with only first attribute like 1kg. What variable i have to use to show only first attribute? I want to make a line that price is for 1kg and other attributes is 2kg 5kg etc. I hope it is clear  :)

Link to comment
Share on other sites

  • 2 weeks later...

Hello
I use PS 1.6.1.4 and it works great, but wondering one thing, is it possible to get it to product.tpl
It´s take so mutch size from my product-list.tpl

And if it possible to show :

Available sizes:
1, size 1, size 2, size 3, size 4
2, size 1, size 2, size 3, size 4, size 5

Becuse now i have so trubble to show witch options is Available or not.

http://prntscr.com/d3g03x

Link to comment
Share on other sites

  • 5 weeks later...



Hello, please i just want to ask for one thing. I need to show combinations for products which are allowed for back ordering. Can you please help me , what to edit in php or tpl? Thank you so much. Now it is showing attributes but on products, which are in stock. THANKS !!!




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

  • 1 month later...
  • 3 weeks later...

Hi ! 

I use this module in version 1.6.1.10 and works well on the product list with filters, while on the main page in the news, promotions ... does not work well on all products will be the same size.  

When the first time I'm on the main page is ok, but when I'm on the product list by category and back to the main page then all products will be the same size.

Any idea?

				{if $PS_STOCK_MANAGEMENT && isset($product.available_for_order) && $product.available_for_order && !isset($restricted_country_mode)}
										<span class="unvisible">
											{if ($product.allow_oosp || $product.quantity > 0)}
													<link itemprop="availability" href="https://schema.org/InStock" />{if $product.quantity <= 0}{if $product.allow_oosp}{if isset($product.available_later) && $product.available_later}{$product.available_later}{else}{l s='In Stock'}{/if}{else}{l s='Out of stock'}{/if}{else}{if isset($product.available_now) && $product.available_now}{$product.available_now}{else}{l s='In Stock'}{/if}{/if}
											{elseif (isset($product.quantity_all_versions) && $product.quantity_all_versions > 0)}
													<link itemprop="availability" href="https://schema.org/LimitedAvailability" />{l s='Product available with different options'}

											{else}
													<link itemprop="availability" href="https://schema.org/OutOfStock" />{l s='Out of stock'}
											{/if}
										</span>
									{/if}
									
									{hook h="displayProductPriceBlock" product=$product type="price"}
									{hook h="displayProductPriceBlock" product=$product type="unit_price"}
																	
									{Hook::exec('displayProductOnList', $product)}
Edited by Agnieszka1983 (see edit history)
Link to comment
Share on other sites

  • 2 months later...

ohh i missed this topic, anyway glad to hear that it works. so, finally we have working solution :D i will release free module based on this topic, it's worth to publish it :)

 

any suggestions? 

Hello Vekia!

I'm still waiting for your free module :)

where i can find it?

 

Thx a lot :)

Link to comment
Share on other sites

  • 1 year later...
  • 7 months later...
  • 5 months 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...