Jump to content

kostandin

Members
  • Posts

    1
  • Joined

  • Last visited

Profile Information

  • First Name
    Kostandin
  • Last Name
    Dimitrijevic

Recent Profile Visitors

73 profile views

kostandin's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. I'm working with PrestaShop 1.7.1.0 (default installation). Shop is set to debug mode with cache disabled. I have a backend module that has both backend and frontend controllers. Shop settings: Task: I want to generate link to my frontend controller and send it to external system so it can call it. I need to generate this link sometimes from my module's backend controller and sometimes from my module's frontend. My solution: From both controllers I use this code to generate link URL: $url = Context::getContext()->link->getModuleLink('cleverreach', 'auth'); Problem: Link is not generated the same from backend and from frontend in different scenarios. Background: I had one shop with multistore option disabled. With this setup, links were generated properly. Then, I enabled multistore option and added additional shop group called "Second", added one store to it and made it default: Store settings are here: Settings for store "demoshop 1.7": Settings for store "second": With this setup, from backend controller I got this link: http://testshops.rs/prestashop1.7/en/module/cleverreach/auth This URL works properly and links to my controller. But when I use the same code from this frontend controller ("auth"), I get this link: http://testshops.rs/prestashop1.7/en/en/module/cleverreach/auth Note that "/en" prefix is added twice. This link also works but it creates a problem for external system that uses it because those 2 links do not match. Now, I could fix this problem with this code: $url = Context::getContext()->link->getModuleLink( 'cleverreach', 'auth', array(), null, null, Configuration::get('PS_SHOP_DEFAULT') ); So, I added default shop ID and this generated this link in both cases: http://testshops.rs/prestashop1.7/en/module/cleverreach/auth Now I wanted to test this code if multistore is not enabled so I went to configuration and disabled multistore. I logged out, cleared cache (just in case) and tested again, but the links are now again different. From backend controller it is: http://testshops.rs/prestashop1.7/en/module/cleverreach/auth and from frontend controller it is again with double "/en" prefix: http://testshops.rs/prestashop1.7/en/en/module/cleverreach/auth I checked context object and shop and with this setup, backend is returning "second" for context->shop, and frontend is returning "demoshop 1.7", which probably causes the error. The main problem is that with this setup (enabled multistore, set second store as default and then disabled multistore) I cannot manage to get the same link anyhow. Is this a bug or I'm missing something? Thanks. EDIT: I have 3 languages in my shop, this is why /en is added, but the problem is still the same: URLs are not the same.
×
×
  • Create New...