Skip to main content

Question about vendor listing

More
9 years 7 months ago #261208 by ronron
-- HikaShop version -- : 2.6.3
-- HikaMarket version -- : 1.7.0
-- Joomla version -- : 3.4.5
-- PHP version -- : 5.5
-- Error-message(debug-mod must be tuned on) -- : none

hi

i created a hikamarket vendor listing menu. MY problem is that it displays all users even do they have not posted anything. i think it has something to do with my setting to simplified registration with password and vendor automatic creation.

is there a way not to display vendors who just registered and has not actually posted anything? or maybe not to display vendors who has not completed certain fields?

thanks

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

More
9 years 7 months ago - 9 years 7 months ago #261293 by Jerome
Hello,

Sorry for the delay.
I needed to performed some tests in order to be sure of my answer.

I understand your request and it could be something interesting to put in HikaMarket.
Creating a dynamic filter in order to check the vendor completion will be a little bit complicated.
For the products, it requires to add a link with the hikashop product table.

In HikaMarket, you have a trigger for the vendor listing :
www.hikashop.com/support/documentation/1...VendorListingDisplay

So thanks to a custom plugin, you can add your own filters and you can modify dynamically the query which will be processed by HikaMarket.
In the parameter $sql_params, you can add a SQL join for the product table.
But if you want to only display the vendor with products, it will require to perform an "HAVING" in the SQL query and currently, there is no parameter for that (so we need to add it).

In the file "components/com_hikamarket/views/vendormarket/view.html.php"

Replacing:
Code:
$order = '';
By
Code:
$order = ''; $having = array();

And
Code:
'order_accept' => &$orderingAccept );
By
Code:
'order_accept' => &$orderingAccept, 'having' => &$having );

And finally
Code:
if($this->params->get('random')) $order = ' ORDER BY RAND()';
By
Code:
if($this->params->get('random')) $order = ' ORDER BY RAND()'; if(!empty($having)) $order = ' HAVING ' . implode(' AND ', $having) . $order;

Then it will be possible in the plugin to modify "join" to like with the HikaShop table products, "select" to get the count of products and "having" to only get vendor with products.
Code:
$sql_params['join']['vendor_products'] = 'LEFT JOIN #__hikashop_product AS hkp ON hkp.product_vendor_id = vendor.vendor_id AND hkp.product_published = 1 and hkp.product_type = \'main\''; $sql_params['select']['vendor_products'] = 'COUNT(hkp.product_id) AS vendor_products'; $sql_params['having']['vendor_products'] = 'vendor_products > 0';

And it should do the trick !

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.
Last edit: 9 years 7 months ago by Jerome.
The following user(s) said Thank You: ronron

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

More
9 years 7 months ago #261709 by ronron
hi Jerome and thank you

i have been trying this but i cant move forward.

i always get this error

Warning

JInstaller: :Install: Can't find Joomla XML setup file.
×
Error

Unable to find install package

i attached the plugin i created, maybe you can point me to the right direction?

thank you
This attachment is hidden for guests.
Please log in or register to see it.

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

More
9 years 7 months ago #261711 by Jerome
Hi,

Your XML is malformed, the header contains special characters instead of classical double quotes for the version parameter :
Code:
<extension type="plugin" version=“2.5” method="upgrade" group="hikamarket">

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.

More
9 years 7 months ago #261836 by ronron
your right, thank you.

i got it to install but having this error
Code:
Unknown column 'vendor_products' in 'having clause' SQL=SELECT COUNT(vendor.vendor_id) FROM #__hikamarket_vendor AS vendor LEFT JOIN #__hikashop_product AS hkp ON hkp.product_vendor_id = vendor.vendor_id AND hkp.product_published = 1 and hkp.product_type = 'main' WHERE (vendor_published = 1) AND (vendor.vendor_id > 1) HAVING vendor_products > 0 ORDER BY vendor.vendor_id ASC

what could it be?

thanks

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

More
9 years 7 months ago #261839 by Jerome
Hi,

Please replace the line
Code:
$db->setQuery('SELECT COUNT(vendor.vendor_id) ' . $query);
By
Code:
$db->setQuery('SELECT COUNT(vendor.vendor_id) FROM '.hikamarket::table('vendor').' AS vendor ' . $sql_joins . $filters);
So it will avoid the issue.

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.
The following user(s) said Thank You: ronron

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

More
9 years 7 months ago - 9 years 7 months ago #262090 by ronron
hi thanks jerome

the error is gone but no vendor is displaying even do vendors have products.
Code:
<?php class plgHikamarketVendor_wproduct_only extends JPlugin { public function onBeforeVendorListingDisplay(&$view, &$sql_params) { $sql_params['join']['vendor_products'] = 'LEFT JOIN #__hikashop_product AS hkp ON hkp.product_vendor_id = vendor.vendor_id AND hkp.product_published = 1 and hkp.product_type = \'main\''; $sql_params['select']['vendor_products'] = 'COUNT(hkp.product_id) AS vendor_products'; $sql_params['having']['vendor_products'] = 'vendor_products > 0'; } }

thanks so much
Last edit: 9 years 7 months ago by Jerome. Reason: indent code

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

More
9 years 7 months ago #262142 by Jerome
Hi,

I'm sorry but if I run the query in PHPMyAdmin
Code:
SELECT vendor.*, COUNT(hkp.product_id) AS vendor_products FROM #__hikamarket_vendor AS vendor LEFT JOIN #__hikashop_product AS hkp ON hkp.product_vendor_id = vendor.vendor_id AND hkp.product_published = 1 and hkp.product_type = 'main' WHERE (vendor_published = 1) AND (vendor.vendor_id > 1) HAVING vendor_products > 0 ORDER BY vendor.vendor_id ASC
(and I replace "#_" by my joomla database prefix)
I right code my vendors with products.

So please check that query in your end and you can see to perform a display of the SQL query just before his processing to check that you're having the same content.

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.

More
9 years 7 months ago #262256 by ronron
hi thank you

i tested this but it only displayed one vendor. it shows the main vendor

i tried to change WHERE (vendor_published = 1) to WHERE (vendor_published = 0) just to test it and it displayed the first vendor that is unpublished.

i dont know if it makes sense but it always displays the first vendor in the table

i tried to change hkp.product_type = 'main' to hkp.product_type = 'main categories' because i changed my category from main to main category but it still displays the main vendor which happens to be the first vendor in the table. One difference from setting 'main' to 'main category' is the vendor_products. for 'main' = 28 for 'main category' = 0.

what else could i check?

thanks

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

More
9 years 7 months ago #262280 by Jerome
Hi,

I'm sorry but I don't understand what you're trying to do.
In my side, the query is working perfectly and I got the list of published vendor with published products.

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.

More
9 years 7 months ago - 9 years 7 months ago #262523 by ronron
hi jerome

first of all thank you for your patience.

to make things clear please let me explain.

i changed the file components/com_hikamarket/views/vendormarket/view.html.php and it is attached here.
i created the plugin with the following codes

unfortunately its not working on my end.

it is only displaying one vendor

what i am requesting is to display vendors with products only

thanks
Last edit: 9 years 7 months ago by ronron.

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

More
9 years 7 months ago #262563 by Jerome
Hi,

Try to perform a "group by" on the vendor id to avoid another kind of aggregation.
Code:
$order = ''; $having = array();
By
Code:
$order = ''; $group_by = array(); $having = array();
Code:
'order_accept' => &$orderingAccept, 'having' => &$having
By
Code:
'order_accept' => &$orderingAccept, 'group_by' => &$group_by, 'having' => &$having
Code:
if(!empty($having)) $order = ' HAVING ' . implode(' AND ', $having) . $order;
By
Code:
if(!empty($having)) $order = ' HAVING ' . implode(' AND ', $having) . $order; if(!empty($group_by)) $order = ' GROUP BY '.implode(', ', $group_by) . $order;

Then you will be able to push "vendor.vendor_id" in the group_by ; to get a query like that
Code:
SELECT vendor.*, COUNT(hkp.product_id) AS vendor_products FROM #__hikamarket_vendor AS vendor LEFT JOIN #__hikashop_product AS hkp ON hkp.product_vendor_id = vendor.vendor_id AND hkp.product_published = 1 and hkp.product_type = 'main' WHERE (vendor_published = 1) AND (vendor.vendor_id > 1) GROUP BY vendor.vendor_id HAVING vendor_products > 0 ORDER BY vendor.vendor_id ASC
And it should display you more than one result entry.

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.

More
9 years 7 months ago #262862 by ronron
hi jerome,

again thank you

its working now but with a little bug. the plugin is now able to display all vendors that are with products. the only problem is when you choose to navigate using pagination.

when you use pagination and select the button to go to the last part of the record. what happens is everything or all records disappears.

please check this link link

i modified the plugin contents to this
Code:
<?php /** * @package HikaMarket for Joomla! * @version 1.7.2 * @author Obsidev S.A.R.L. * @copyright (C) 2011-2016 OBSIDEV. All rights reserved. * @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html */ defined('_JEXEC') or die('Restricted access'); ?><?php class plgHikamarketVendor_wproduct_only extends JPlugin { public function onBeforeVendorListingDisplay(&$view, &$sql_params) { $sql_params['join']['vendor_products'] = 'LEFT JOIN #__hikashop_product AS hkp ON hkp.product_vendor_id = vendor.vendor_id AND hkp.product_published =1 AND hkp.product_type = \'main\''; $sql_params['select']['vendor_products'] = 'COUNT(hkp.product_id) AS vendor_products '; $sql_params['having']['vendor_products'] = 'vendor_products > 0 '; $sql_params['group_by']['vendor_products'] = 'vendor.vendor_id'; }}

and the screenshot below

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

More
9 years 7 months ago #262902 by Jerome
Hi,

Sure the pagination cannot work properly because of :
Code:
$db->setQuery('SELECT COUNT(vendor.vendor_id) FROM '.hikamarket::table('vendor').' AS vendor ' . $sql_joins . $filters);

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.

More
9 years 7 months ago #263485 by ronron
thank you jerome

i still cant get this to work.

can you tell me what the code should be?

i already tried to add $order but still dosnt work.
Code:
$db->setQuery('SELECT COUNT(vendor.vendor_id) FROM '.hikamarket::table('vendor').' AS vendor ' . $sql_joins . $filters . $order);

thank you for your patience.

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

More
9 years 6 months ago #263505 by Jerome
Hi,

Like I wrote you, the pagination is handle by the query I mentioned.
That query do not include the filtering on the products, it does not have the "HAVING" clause and because the having need a value from the "select" and you can't add all "select" fields to perform the "count" ; we got a situation.

If you find a solution to perform a query without needed the "HAVING" clause but just with a "INNER JOIN" (and maybe a sub queyr), it would do the trick.

By I'm afraid that I can't modify more HikaMarket and I think that I'll remove the "having" support due to the issue with the pagination.

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.

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