Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle multistore customers sharing in customers listing at group level #16047

Merged
merged 1 commit into from Oct 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/Adapter/Shop/Context.php
Expand Up @@ -72,6 +72,23 @@ public function getContextListShopID($share = false)
return Shop::getContextListShopID($share);
}

/**
* Return the result of getContextListShopID() for customers usecase
* This handles the "multishop sharing customer" feature setting
*
* @return array
*/
public function getContextListShopIDUsingCustomerSharingSettings()
{
$groupSettings = Shop::getGroupFromShop(Shop::getContextShopID(), false);

if ($groupSettings['share_customer']) {
return Shop::getContextListShopID(Shop::SHARE_CUSTOMER);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should manage the other two sharing types since we're at it ^^
Shop::SHARE_ORDER and SHOP::SHARE_STOCK
cd

public static function getSharedShops($shop_id, $type)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we should also take a look at other places where this method is used like:

$id_shops = (new Context())->getContextListShopID();

But I guess this bug only occurs for entities that have sharing capabilities, so Customer, Order, Stock Then we must be careful about (develop branch only):

} else {
return Shop::getContextListShopID();
}
}

/**
* Get if it's a GroupShop context.
*
Expand Down
Expand Up @@ -66,7 +66,7 @@ services:
arguments:
- '@prestashop.core.query.doctrine_search_criteria_applicator'
- "@=service('prestashop.adapter.legacy.context').getContext().language.id"
- '@=service("prestashop.adapter.shop.context").getContextListShopID()'
- '@=service("prestashop.adapter.shop.context").getContextListShopIDUsingCustomerSharingSettings()'
public: true

prestashop.core.grid.quer_.builder.language:
Expand Down