You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

JRoute on multilang site to products with different sef for each language

Started by berghoff, April 04, 2024, 14:25:51 PM

Previous topic - Next topic



I am building a product listing for each specific language I have on my site using combination of JRoute:
$uri = $live_site.'uk/'.JRoute::_('index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id='.$product_id.'&virtuemart_category_id='.$product_cat_id));

But every time I get the SEF urls for deafault language.
I tried to add &lang=uk to the Jroute but it is being skipped by router.
How can I set the router for using specific language?

Whole code looks as follows:
efine('_JEXEC', 1);

define('JPATH_BASE', dirname(__DIR__, 4));
require_once JPATH_BASE . '/includes/defines.php';
require_once JPATH_BASE . '/includes/framework.php';
require_once JPATH_BASE . '/plugins/behaviour/compat/src/classmap/classmap.php';

$container = \Joomla\CMS\Factory::getContainer();

$container->alias('session.web', '')
    ->alias('session', '')
    ->alias('JSession', '')
    ->alias(\Joomla\CMS\Session\Session::class, '')
    ->alias(\Joomla\Session\Session::class, '')
    ->alias(\Joomla\Session\SessionInterface::class, '');

$app = $container->get(\Joomla\CMS\Application\SiteApplication::class);
\Joomla\CMS\Factory::$application = $app;

use Joomla\CMS\Factory;
use Joomla\CMS\Language\Language;


VmConfig::set('vmlang', 'uk_ua');//without this I get always default site language
$db = Factory::getContainer()->get('DatabaseDriver');
$vmlang = VmConfig::get('vmlang', 'uk_ua');

$uri = $live_site.'uk/'.JRoute::_('index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id='.$product_id.'&virtuemart_category_id='.$product_cat_id));

//sef is from default site language