Show three last products of vendors in vendor list

  • Posts: 54
  • Thank you received: 2
8 years 8 months ago #211358

-- HikaShop version -- : 2.5.0
-- HikaMarket version -- : 1.6.5
-- Joomla version -- : 3.4.3

Hi again,
I want to show last three products of vendors in vendor list page:
http://homatia.com/%D9%81%D8%B1%D9%88%D8%B4%DA%AF%D8%A7%D9%87-%D9%87%D8%A7/vendormarket/listing.html.html
can you help me what code I should add to vendor view?
(I searched but couldn't find anything related, so I created a new topic)
Thanks in advance.

Please Log in or Create an account to join the conversation.

  • Posts: 26019
  • Thank you received: 4005
  • MODERATOR
8 years 8 months ago #211359

Hi,

It will highly depend on your product structure.
The setting "synchronize" of the modules allow to link the product listing with the current page.
So with an HikaShop category menu, you will filter the products of the selected category ; with an HikaMarket vendor page you will filter the products of the selected vendor.
But in a vendor listing, there is no value to synchronize with ; so in that case the best is to use a "fixed" module and set the filters yourself... But it depends on your structure.

Afterwards, to display the last 3 products, you just have to put a limitation to 3 elements and set the ordering on the product_id.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

Please Log in or Create an account to join the conversation.

  • Posts: 54
  • Thank you received: 2
8 years 8 months ago #211412

Thanks for your response.
I meant something like etsy which shows under every vendor three small images of last products of that vendor. See the attachment.
I want code that I can add to vendor view to show this.
Thanks

Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 26019
  • Thank you received: 4005
  • MODERATOR
8 years 8 months ago #211438

Hi,

Thanks for the clarification.

It requires some customization of the "vendor | listingcontainer_div" and "vendor | listingcontent_img_title" views in order to load the required data using some SQL queries and display them.
First you need to retrieve the "vendor_id" of all vendors in the listing

$vendor_ids = array();
foreach($this->rows as $row) {
	$vendors_ids[ (int)$row->vendor_id ] = (int)$row->vendor_id;
}
Thanks to that, you will be able to load the product counter for the vendors.
$this->product_counter = array();
if(!empty($vendor_ids)) {
	$db = JFactory::getDBO();
	$query = 'SELECT vendors.vendor_id, count(products.product_id) FROM '.hikamarket::table('vendor') .' AS vendors LEFT JOIN '.hikamarket::table('shop.product').' as products on vendors.vendor_id = products.product_vendor_id WHERE products.product_type = '.$db->Quote('main').' AND products.product_published = 1 AND vendors.vendor_id IN ('.implode(',' $vendor_ids).') GROUP BY vendors.vendor_id;
	$db->setQuery($query);
	$this->product_counter = $db->loadObjectList('vendor_id');
}

After that, in the "listincontent_img_title" (which is I think the most appropriate view) ; you can check the content of the product_counter array and see if the vendor have products (You can also display that counter in the view).
If so, you can make a new query in order to load the last products of the vendors.
I don't see faster way to achieve that goal using less SQL queries ; so depending the number of vendors in the listing and the number of products in your database, it could ask for more CPU resources.
$query = 'SELECT * FROM '. hikashop_table('product') . ' WHERE product_published = 1 AND product_type = ' . $db->Quote('main') . ' AND product_vendor_id = '.(int)$this->row->vendor_id.' ORDER BY product_created DESC';
$db->setQuery($query, 0, 4);
$vendor_products = $db->loadObjectList('product_id');

For the view content, I recommend you to take a look at the current HikaShop views ; so you can use them as a base to display the products tiles.

www.hikashop.com/support/support/documen...ize-the-display.html

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

Please Log in or Create an account to join the conversation.

  • Posts: 54
  • Thank you received: 2
8 years 8 months ago #211532

Thanks a lot Jerome. :)
I just edited a little and it works like a charm. See this:
vendor list

The following user(s) said Thank You: Jerome

Please Log in or Create an account to join the conversation.

Moderators: Obsidev
Time to create page: 0.075 seconds
Powered by Kunena Forum