We offer professional Design/Code Customisation and Website Optimisation Service Request Customisation
  • Status: Closed
  • Closed by: Marek (marek)
  • Closed on: 10.05.18, 23:41
  • Reason: Closed
  • Comment: Glad to help!

Ticket #11948 - Wrong shop context when updating menu

When using the menu builder in a multi shop, the code for updating a menu via AJAX is using the wrong shop context (always using shop 1).
See pk_menu/ajax_pk_menu.php.

- Select another shop than the default one in PrestaShop
- Go to Promokit → Venedor Menu
- Create a menu and select “Build submenu” - Create some columns
- Now try to change the change the column positions using drag & drop.
- The updated positions are not saved because the wrong shop_id is used in the queries.

Hope you can help us out!

This ticket does not depend on any other tickets.

Marek (marek) 30 Mar 2018, 19:55

I'll check that and try to fix as soon as possible

Marek (marek) 02 Apr 2018, 14:16

I just make a could of tests on our demo server and localhost and I do not see the issue. I only noticed it could be in case your shop is in maintenance mode

Aris Schlingmann (aris-comm-on-nu) 03 Apr 2018, 09:45

That's strange, I do have the issue both on my localhost (no maintenance mode) and online (maintenance mode) environments. However, the code in ajax_pk_menu.php uses standard PrestaShop session/context initialization, so there is not much you can do, I think. I'll be using a temporary fix for my environment, so you can close this issue.
Thanks for your help!

Marek (marek) 03 Apr 2018, 10:04

What is your fix? maybe I understand what's wrong if you will share it with me

Aris Schlingmann (aris-comm-on-nu) 03 Apr 2018, 11:40

Thanks for thinking along.

My fix is to use the back-office init.php instead of the front-office init.php. It works, but it's no clean solution because I can't get the admin directory properly, see below...

First lines of ajax_pk_menu.php

if (!defined('_PS_ADMIN_DIR_')) {
    define('_PS_ADMIN_DIR_', '../../adminXXXX');

Marek (marek) 03 Apr 2018, 11:41

Thank you, I'll check that out