Author Topic: Select product detail in menu  (Read 1738 times)

MKI-Miro

  • Jr. Member
  • **
  • Posts: 157
Select product detail in menu
« on: January 27, 2018, 18:22:01 pm »
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

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 3393
  • Joomla & Virtuemart addon developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3.0.x.y
Re: Select product detail in menu
« Reply #1 on: January 28, 2018, 15:57:47 pm »
When I want to create link to product detail should only display 1 product.
What are the X products ?

MKI-Miro

  • Jr. Member
  • **
  • Posts: 157
Re: Select product detail in menu
« Reply #2 on: January 28, 2018, 16:02:24 pm »
menu-> edit menu item (product deail layout)-> here is dropdown "Select product" and here i dont see all products

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 3393
  • Joomla & Virtuemart addon developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3.0.x.y
Re: Select product detail in menu
« Reply #3 on: January 28, 2018, 16:17:20 pm »
This is simple, enable VM debug and you see why :
Message
Quote
1 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 ?

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 9667
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: Select product detail in menu
« Reply #4 on: January 30, 2018, 23:45:36 pm »
yeh, someone need to enhance the field "product" in /administrator/components/com_virtuemart/fields. Of course that would be nice.
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 3393
  • Joomla & Virtuemart addon developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3.0.x.y
Re: Select product detail in menu
« Reply #5 on: January 31, 2018, 03:07:13 am »
Can you not use related product search as field and use ajax ?

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 9667
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: Select product detail in menu
« Reply #6 on: January 31, 2018, 10:27:20 am »
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 should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

MKI-Miro

  • Jr. Member
  • **
  • Posts: 157
Re: Select product detail in menu
« Reply #7 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.

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 3393
  • Joomla & Virtuemart addon developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3.0.x.y
Re: Select product detail in menu
« Reply #8 on: January 31, 2018, 11:53:58 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

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 3393
  • Joomla & Virtuemart addon developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3.0.x.y
Re: Select product detail in menu
« Reply #9 on: January 31, 2018, 16:27:39 pm »
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

Code: [Select]
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
Code: [Select]
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)

MKI-Miro

  • Jr. Member
  • **
  • Posts: 157
Re: Select product detail in menu
« Reply #10 on: January 31, 2018, 16:35:04 pm »
I have to do it or virtuemart dev team will implement it?

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 3393
  • Joomla & Virtuemart addon developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3.0.x.y
Re: Select product detail in menu
« Reply #11 on: January 31, 2018, 16:51:25 pm »
I hope Team change it,
But you can try this code, simply do a backup before of this file.

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 9667
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: Select product detail in menu
« Reply #12 on: February 01, 2018, 11:45:06 am »
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.
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 3393
  • Joomla & Virtuemart addon developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3.0.x.y
Re: Select product detail in menu
« Reply #13 on: February 01, 2018, 13:32:16 pm »
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.

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 9667
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: Select product detail in menu
« Reply #14 on: February 05, 2018, 10:36:01 am »
No, the problem is to write a dropdown with so many entries. the next shop has 50k products. It does not work that way.
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/