Jump to content

How to display multiple supplies on product page


Okko

Recommended Posts

I'm newbie at Prestashop

 

I have product Blouse from manufacturer (brand) Zara with 2 suppliers: Distributor 1 and Distributor 2

 

How to display all suppliers on product page?

 

Like:

 

Blouse

Supplier: - Distributor 1

               - Distributor 2

 

I'm using Prestashop 1.6.0.6

 

thanks a lot for your help

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

Hi Okko,

 

You do have interesting point. Already Presta support multiple suppliers for each product along with their own prices.

I'm also searching for a way to display all suppliers on a product page to let customer choose any of supplier to buy from.

 

Did you got success in this? Please share the solution to it.

 

@vekia

Sir please look into it as you know it can help us use Presta in many ways.

 

Thanks

Link to comment
Share on other sites

  • 6 months later...

Hello, 

I wanna share with you the solution i use for list all suppliers : 

 

in file

/override/controllers/front/ProductController.php

something like : 

class ProductController extends ProductControllerCore
{
	public function initContent()
	{
		parent::initContent();
                foreach (ProductSupplier::getSupplierCollection($this->product->id, true)->getResults() as $productSupplier) {
                   $suppliers[] = new Supplier($productSupplier->id_supplier, $this->context->language->id);
                }
                $this->context->smarty->assign('suppliers' , $suppliers );
	}
	
}

in product.tpl in my theme directory : 

<p id="supplier">
    <label for="product_supplier">{l s='Les mamies qui tricotent cet article :'} </label>
    <span class="editable">
        {if isset($suppliers)}
            {foreach from=$suppliers item='supplier' name='supplier_list'}
                {if {$supplier->id_supplier} !=0}
                    <a   href="{$link->getsupplierLink($supplier->id_supplier, $supplier->link_rewrite)|escape:'html':'UTF-8'}" 
                         title="{l s='More about' mod='blocksupplier'} {$supplier->name}">
                        <img src="{$img_ps_dir}/su/{$supplier->id_supplier}-small_default.jpg" alt="{l s='une image de '} {$supplier->name}" />
                    </a>
                {/if}
            {/foreach}
        {/if}
    </span>
</p>

This work and it's not too crappy ;)

 

But i wonder, is it better to create a module rather than override core class like this ?

Especially if you want to distribute a theme ! i'm not sure but it's seems impossible to distribute an override in theme without a module. isn't it ?

Or maybe there is an easier way adding a smarty variable ?

  • Like 3
Link to comment
Share on other sites

Well, depending on how many suppliers you have, creating a new instance of the class for each of them might take down performance a bit. Why not, instead, using a module, as you mentioned, that

 

1- retrieves only necessary data for supplies and assigns it to an available hook

2- use that very same hook to show the table in the product page?

 

If not the second, you could add a further custom hook, that only involves writing a small snippet, and use that in the position you prefer, instead

 

Lastly, I believe product has both id_supplier and supplier_name assigned as variables to the object, so it would only be missing link_rewrite (which is in any case optional to grab the link)

Link to comment
Share on other sites

×
×
  • Create New...