Hi
When I want to create link to product detail in Joomla Menu I dont see all product (only first X products).
Joomla 3.8.3
Virtuemart 3.2.8
Is it bug ?
Kind Regards
Cibuľa Miroslav
When I want to create link to product detail should only display 1 product.
What are the X products ?
menu-> edit menu item (product deail layout)-> here is dropdown "Select product" and here i dont see all products
This is simple, enable VM debug and you see why :
Message
Quote1 vmdebug 2 Languages, default shoplanguage (VmConfig::$jDefLang): fr_fr fr-FR Selected VM language (VmConfig::$vmlang): fr_fr fr-FR SEF: fr
2 vmdebug vmTime: time to load config: 0.00191092491149902
3 vmdebug getVendorId manager
4 vmdebug Active vendor 0 1
5 vmdebug Set 476 to 1
6 vmdebug My Memory Limit in Bytes 536870912
7 vmdebug vmTime: sortSearchQuery products: : 0.031574010848999
8 vmdebug Better not to display more than 700 products
SO currently it's not possible, because virtuemart do not use a modal with search but try to display all products from Db and this is not possible(imagine you have 100000 products).
You need to check with Max if he want to rewrite this and use a modal or an ajax search, so you can filter and display some products from db only
Note that it's another problem with current solution. If a day you have more then 700 product and had 700 before, you can loose the curent value in some case.
Max and dev team, can you fix this ?
yeh, someone need to enhance the field "product" in /administrator/components/com_virtuemart/fields. Of course that would be nice.
Can you not use related product search as field and use ajax ?
It can be used as pattern. It can be even used for the ajax call, maybe. But someone needs to write the js for it. this is the first request for this feature. The reason is simple, the feature was never meant for big shops. The idea of this feature is only usefull for shops with less than 10 products, actually mainly for shops with one product. They dont want a product listing.
MKI-Miro use a profiler, joomla debug or vmdebug vmtime to measure the loading/rendering of your page. There are tests, which show that a lot time is spent for the joomla menu. So adding a lot products per menuitem will slow down your store. So to have an ajax for the product field would be nice, but more interesting for other uses of the product field.
I have few categories where only product exists so thats why I really need it. Currently I solved it be replacing ID in db.
Quote from: MKI-Miro on January 31, 2018, 11:11:34 AM
I have few categories where only product exists so thats why I really need it. Currently I solved it be replacing ID in db.
You can redirect on couting product.
If count product ==1 then redirect.
This trick was used in Virtuemart 1 in the core
I quick checked in the field, why using model here?
This dont need so many complexity.
in file JOOMLAROOT/administrator/components/com_virtuemart/fields/product.php
private function _getProducts() {
if (!class_exists('VmModel'))
require(VMPATH_ADMIN . DS . 'helpers' . DS . 'vmmodel.php');
$productModel = VmModel::getModel('Product');
$productModel->_noLimit = true;
if(vmAccess::manager('managevendors')){
$productModel->virtuemart_vendor_id = 0;
}
$products = $productModel->getProductListing(false, false, false, false, true,false);
$productModel->_noLimit = false;
$i = 0;
$list = array();
foreach ($products as $product) {
$list[$i]['value'] = $product->virtuemart_product_id;
$list[$i]['text'] = $product->product_name. " (". $product->product_sku.")";
$i++;
}
return $list;
}
replace with
private function _getProducts() {
$db = JFactory::getDbo();
$query = 'select p.virtuemart_product_id AS value,IFNULL(l.product_name, fb.product_name) AS text from #__virtuemart_products as p
LEFT JOIN #__virtuemart_products_'.VMLANG.' as l ON l.virtuemart_product_id = p.virtuemart_product_id';
$query .= ' LEFT JOIN #__virtuemart_products_en_gb as fb ON fb.virtuemart_product_id = p.virtuemart_product_id AND l.virtuemart_product_id is NULL';
$query .= ' order by text ASC LIMIT 0,10000';
$db->setQuery($query);
$result = $db->loadObjectList();
return $result;
}
Note that i dont implemented correctly the fallback here, but this queries run in 0.05 secondes in a good shared server with 3245 results(and display fast)
I have to do it or virtuemart dev team will implement it?
I hope Team change it,
But you can try this code, simply do a backup before of this file.
lol...
man, the point is not the model. the point is that you MUST use a limit. You just set a limit of 10 000. I could also just do that in the model. I can also just simple set a simple boolean, which disables the hardcoded limit.
There is a reason for the hardcoded limit.
Max the problem is that you load many datas to get the product name and id only, so you cannot load this in 0.05 secondes, try to load 5000 products and check how much time the current Vm core solution need.
I had exactly same problem for a customer to load 1200 categories to get the tree, you need more then 8 secondes first time, so i had to write a new category module.
I constantly change my own code, to get better result in my extensions myself, it's not to blame the team.
No, the problem is to write a dropdown with so many entries. the next shop has 50k products. It does not work that way.
What about just to make input field for product id? simple and quick to do
Quote from: MKI-Miro on February 05, 2018, 17:55:18 PM
What about just to make input field for product id? simple and quick to do
In this case users cry because they have to go in Vm list to find the ID.
Actually, Miro. there is a lot better solution for your problem. I think.
We could add a feature, which directly displays the productdetail, if only one product was found. That is also handy for the search. We can add a hidden config, so people can disable it.
yes thats also solution :)
Quote from: Milbo on February 06, 2018, 17:01:01 PM
Actually, Miro. there is a lot better solution for your problem. I think.
We could add a feature, which directly displays the productdetail, if only one product was found. That is also handy for the search. We can add a hidden config, so people can disable it.
A simple count product = 1 > Joomla redirect to this product works.
Exactly and it makes a lot more sense for anyone.