Sunday, December 9, 2012

Suppliers...

I wanted to show a list of Suppliers on the left and if one was clicked show a page in the center with address etc to that Supplier.
This showed to be quite a challenge.

The first obstacle was that the link on the title SUPPLIERS didn't work (this was not important, but annoying).
It turned out that I had to check Display suppliers and manufacturers in Preferences/General, which may seem natural except for the description of what that meant, which reads Display suppliers and manufacturers lists even if corresponding blocks are disabled.
My Manufacturers Block is disabled, but of course no Manufacturers showed when I ticked Yes...

No, the first obstacle was that the logos didn't show up with IE. This was because $mediumSize.width and $mediumSize.height wasn't defined, I removed that code and hardcoded a width of 200.

Then for the contact information for the Suppliers.
The module is meant to just list all products supplied by the Suppliers, I don't know why there is address etc to be filled out in the BO because AFAIK that information is never used anywhere.

I had to make the information available to themes/supplier.tpl
I inserted code in classes/supplier.php to fetch it from the database, it turned out to be the wrong place and/or file so I won't give all details but basically
$query->select ' ... a.`id_supplier.address1`');
$query->leftjoin('address', 'a', 's.`id_supplier` = a.`id_supplier`');

This turned out to make the address available to themes/supplier-list.tpl but not to themes/supplier.tpl so I did a ugly hack in suppliercontroller.php
I had the data in $suppliers but not in $this->supplier, so I looped through $suppliers and pulled the wanted fields into standalone variables, i.e.
$addr1 = $row['address1'];
and make those available with i.e.
'addr1' => $addr1

Finally I could use e.g. {$addr1} in themes/supplier.tpl


3 comments:

  1. Can you give me the code for display the block of 'other products from this manufacturer' on product page?

    ReplyDelete
  2. I believe that is the default behaviour

    ReplyDelete
  3. Good day to everyone. I invite you to know my blog, where I have frequent entries on various Prestashop themes, which are
    of interest for people who are just beginning in this world of e-commerce, or for those who already have experience using
    this tool https://prestashopencolombia.blogspot.com/
    I hope you like it and if you like you can subscribe.

    ReplyDelete