News:

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

berghoff

Hi,

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', 'session.web.site')
    ->alias('session', 'session.web.site')
    ->alias('JSession', 'session.web.site')
    ->alias(\Joomla\CMS\Session\Session::class, 'session.web.site')
    ->alias(\Joomla\Session\Session::class, 'session.web.site')
    ->alias(\Joomla\Session\SessionInterface::class, 'session.web.site');

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

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

require(JPATH_ADMINISTRATOR.'/components/com_virtuemart/helpers/config.php');
VmConfig::loadConfig();

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