- Posts: 54
- Thank you received: 2
Show three last products of vendors in vendor list
- mehdikazemi
-
Topic Author
- Offline
Less
More
11 years 1 month ago #211358
by mehdikazemi
Show three last products of vendors in vendor list was created by mehdikazemi
-- 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:
homatia.com/%D9%81%D8%B1%D9%88%D8%B4%DA%...et/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.
-- 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:
homatia.com/%D9%81%D8%B1%D9%88%D8%B4%DA%...et/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.
11 years 1 month ago #211359
by Jerome
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.
Replied by Jerome on topic Show three last products of vendors in vendor list
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,
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.
- mehdikazemi
-
Topic Author
- Offline
Less
More
- Posts: 54
- Thank you received: 2
11 years 1 month ago #211412
by mehdikazemi
Replied by mehdikazemi on topic Show three last products of vendors in vendor list
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
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
Please Log in or Create an account to join the conversation.
11 years 1 month ago #211438
by Jerome
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.
Replied by Jerome on topic Show three last products of vendors in vendor list
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
Thanks to that, you will be able to load the product counter for the vendors.
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.
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,
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
Code:
$vendor_ids = array();
foreach($this->rows as $row) {
$vendors_ids[ (int)$row->vendor_id ] = (int)$row->vendor_id;
}
Code:
$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.
Code:
$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.
- mehdikazemi
-
Topic Author
- Offline
Less
More
- Posts: 54
- Thank you received: 2
11 years 1 month ago #211532
by mehdikazemi
Replied by mehdikazemi on topic Show three last products of vendors in 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.202 seconds