Hi guys.
Today came across a small but very pleasant trifle.
I have developed a module integration 1C: Enterprise + Virtuemart, but faced with the problem of counting items in categories. After analyzing the code came across the following function.
public function countProducts($cat_id=0) {
if(!empty($this->_db))$this->_db = JFactory::getDBO();
$vendorId = 1;
if ($cat_id > 0) {
$q = 'SELECT count(#__virtuemart_products.virtuemart_product_id) AS total
FROM `#__virtuemart_products`, `#__virtuemart_product_categories`
WHERE `#__virtuemart_products`.`virtuemart_vendor_id` = "'.(int)$vendorId.'"
AND `#__virtuemart_product_categories`.`virtuemart_category_id` = '.(int)$cat_id.'
AND `#__virtuemart_products`.`virtuemart_product_id` = `#__virtuemart_product_categories`.`virtuemart_product_id`
AND `#__virtuemart_products`.`published` = "1" ';
$this->_db->setQuery($q);
$count = $this->_db->loadResult();
} else $count=0 ;
return $count;
}
It seems everything is harmless, but there is a nasty piece $vendorId = 1;
I wanted to ask: why?
If multiple vendors?
I hope no one was offended stupid question.
Thanks for answers.
Hello,
I have the same on my mind also before some days ... i create the following function for a user that wan't to count the products. But when using multivendors all products are showed right on the front-end, but the count function is calculate only the vendor_id=1.
Take a look here: http://forum.virtuemart.net/index.php?topic=102174.msg367039#msg367039
You can test it and see if there is any issues.
Regards
oh I know how to solve this problem, thanks.
I'm more interested in why so already.
What were they thinking ...
I think because multivendor introduced in v2.0.11 ... before was experimental, so is still in development but works fine, so when that function was build vendor_id = 1 because was the only vendor...
Oh, sorry that the translation from the Russian phrase: "What were they thinking ..." does not convey my true emotions and true its meaning))
but in any case, thanks for the answers
:) np
You could create a new function for that and test it with the multivendor options is everything working ... if is working fine then the dev team will fix it...
Regards