Prestashop: API Multistore

Created on 2 Feb 2019  路  7Comments  路  Source: PrestaShop/PrestaShop

I'm on prestashop 1.6.1.14 and I've enabled multistore. When I try to access the api through the url of my B2B shop, nothing happens and it redirects to the homepage.

For my B2C shop it works but when I go to https://my-shop.com/api/products?id_shop=all it redirects to the homepage with this url https://my-shop.com/?url=products%2F

The redirect rules in my .htaccess are exactly the same for my two url shops.

1.7.5.0 Bug Minor PR available Products To Do WS

All 7 comments

Hi @dimespi,

I manage to reproduce the issue with PS1.7.5.0 & PS1.6.1.23.
Navigating to this link: http://shop.com/api/products&id_shop=all
we are redirected to the Home page (B2B enabled or disabled)
https://drive.google.com/file/d/1_S6Iu1J2mltAjz6lKe07NM2F7g3Aq-DX/view
Also, I manage to reproduce an issue with PS1.7.5.0 (in PS1.6.1.23 is OK)
Navigating to this link: http://shop.com/shop2/api/products&id_shop=2
It provides me all products only displayed in the first shop (created by default) which is wrong, it should display only products created in the shop2 ( behavior ok in PS1.6.1.23.)
I鈥檒l add this to the debug roadmap so that it鈥檚 fixed for PS1.7 [As you can see here聽: the maintenance of PrestaShop 1.6 is extended to June 2019 for security and critical bugs.]
If you have already fixed it on your end or if you think you can do it, please do send us a pull request!

Hi @khouloudbelguith,
I found out that some people had the same issue: http://forge.prestashop.com/browse/BOOM-5556
I'm still trying to figure out where it's coming from.

@dimespi, thanks for your feedback.
The issue is added to our to do list.
Thanks!

Did you find out how to resolve this? I'm using exact online for my B2B shop and my subscription is still active.

@dimespi, sorry not yet.
There are some major issues to solve before this one.
So, it will probably not solved right now.
But PrestaShop is an open source project, so it can be solved before if someone submits a pull request to solve it.
Thanks!

I know 1.6 is deprecated, but we had to fix this for a project in production:

In file webservice/dispatcher.php, add a constant definition before requiring config/config.inc.php:

ob_start();
define('_PS_API_IN_USE_', true);
require_once(dirname(__FILE__).'/../config/config.inc.php');

Modify initialize() method in classes/shop/Shop.php at line 371:

Replace :

if ((!$id_shop && defined('_PS_ADMIN_DIR_')) || Tools::isPHPCLI() || in_array($http_host, $all_media)) {

with :

if ((!$id_shop && defined('_PS_ADMIN_DIR_')) || ('all' === $id_shop && defined('_PS_API_IN_USE_')) || Tools::isPHPCLI() || in_array($http_host, $all_media)) {

I know 1.6 is deprecated, but we had to fix this for a project in production:

In file webservice/dispatcher.php, add a constant definition before requiring config/config.inc.php:

ob_start();
define('_PS_API_IN_USE_', true);
require_once(dirname(__FILE__).'/../config/config.inc.php');

Modify initialize() method in classes/shop/Shop.php at line 371:

Replace :

if ((!$id_shop && defined('_PS_ADMIN_DIR_')) || Tools::isPHPCLI() || in_array($http_host, $all_media)) {

with :

if ((!$id_shop && defined('_PS_ADMIN_DIR_')) || ('all' === $id_shop && defined('_PS_API_IN_USE_')) || Tools::isPHPCLI() || in_array($http_host, $all_media)) {

Thanks for sharing 馃槈this might help 1.6 users looking for this bug

Was this page helpful?
0 / 5 - 0 ratings