News:

Support the VirtueMart project and become a member

Main Menu

bug in Virtuemart Router ?

Started by kiro789, June 20, 2022, 16:29:33 PM

Previous topic - Next topic

ocram44

I encontered this strange behavoiur in Joomla 4.2.2, Virtuemart 4.0.4: After adding a product in the cart a box appears confirming that the product was added to the cart. The box has two button links: "continue shopping" and "go to cart". Both links point to the current page which is correct for "continue shopping" but not for "go to cart". This seems to be a bug in the Virtuemart Router. Is it the same as above? In Joomla 3.10.x it worked fine. Same behaviour when the cart is empty: a button link should lead back to the category shop, but instead it leads to the same page again.
Thank you for any help.

hazael

Quote from: ocram44 on September 15, 2022, 10:07:02 AM
This seems to be a bug in the Virtuemart Router.

Virtuemart doesn't have a problem with that. This is apparently a problem with your custom template or an improperly configured SEF plugin

ocram44

You are right, it is not a bug in the virtuemart router. It seems to be a bug in the Joomla Router. I am using the System SEF Plugin, nothing to configure there and my template is also not causing the problem.

hazael

#18
And after disabling SEF - what is the structure of links to this cart? Are you moved to the cart when you run this link?
Cart link shouldn't be a problem on Joomla 4. I have several pages on my original templates and it works fine.
Generally in Joomla, you should create a link to the shopping cart in the menu builder. If you do not want to publish it on the website, you can create a separate invisible category for such link.

ocram44

#19
Disabling SEF gives the the correct long links. The Problem is in the Joomla Router. I posted it in the Joomla forum:
https://forum.joomla.org/viewtopic.php?f=816&t=996524

mavrosxristoforos

It is true that the Joomla router has changed, but components have adapted and work fine in J4.
When disabling SEF, I don't think the Virtuemart router is used at all. That's why it works. I may be wrong.

ocram44

With SEF enabled the Joomla SEF Router causes the problem, not the VirtueMart SEF Router. The problem is described in the Joomla Forum. See above.

mavrosxristoforos

I saw your post on the Joomla forum.
However, maintaining the menu Itemid is the expected behavior unless it is explicitly set by the provided URL.

ocram44

The component (here Virtuemart) changes the menu itemid but the Joomla Router does not update the menu itemid to the changed one. In 3.10.x it did. That is all what I know. What is intended or not and which side has to change what is beyond my knowledge. I hope someone knows more about this problem and how to solve it.

mavrosxristoforos

#24
The bug, as far as I can identify Virtuemart code, is in components/com_virtuemart/sublayouts/products.php. The supplied $ItemidStr points to the category menu item instead of the product menu item, which then confuses the router. If Joomla 4 component routing didn't work correctly, wouldn't they have seen it already? Instead, it is now the component's responsibility to properly identify the target menu item to be used, which makes some sense from a content-agnostic, component-independent, generic router's point of view.

Of course, I am referring to the original problem mentioned in this post, the one that shows the category view instead of products.

Interestingly enough, I made another test to confirm my point. I manually linked to the product using the correct menu item id from an independent view (even within articles it would work I guess now) and the Virtuemart router points to the correct menu item, with the correct product view showing up. [SEF enabled]

So, theoretically, the solution would either be to overwrite the menu item's properties in the router if such options exist in the URL or include the correct menu item ID in the first place. Probably both would be required to remedy the existing situation that probably includes dozens of templates and thousands of websites with existing template overrides of Virtuemart's views.

kiro789

But this is not some small problem, in this case we can not use fully VM with Joomla 4. So is the problem in Joomla or VM ?

kiro789

I just installed VirtueMart 4.0.7 10699 on Joomla  ‎4.2.3 and the problem was solved :)
Thank you very much!!!

Regards!

GJC Web Design

GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

mavrosxristoforos

Excellent news! I confirm the fix. Hurray!

There's still a small warning, though, just FYI:
Warning: Undefined array key "Itemid" in .../components/com_virtuemart/router.php on line 334

Milbo

Quote from: mavrosxristoforos on September 30, 2022, 20:14:17 PM
Excellent news! I confirm the fix. Hurray!

There's still a small warning, though, just FYI:
Warning: Undefined array key "Itemid" in .../components/com_virtuemart/router.php on line 334
considered (maybe fixed next version, generic fix added). Last version (without this fix though, https://dev.virtuemart.net/attachments/1332/com_virtuemart.4.0.7.10714_package_or_extract.zip)
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/