Skip to content

Commit 6a6c28c

Browse files
committed
MAGETWO-59649: Current store resolver does not work for global scope
2 parents 915e6dd + 06a027f commit 6a6c28c

File tree

6 files changed

+71
-18
lines changed

6 files changed

+71
-18
lines changed

app/code/Magento/BundleSampleData/Setup/Installer.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
namespace Magento\BundleSampleData\Setup;
77

88
use Magento\Framework\Setup;
9+
use Magento\Store\Model\StoreManagerInterface;
10+
use Magento\Store\Model\Store;
911

1012
/**
1113
* Launches setup of sample data for Bundle module
@@ -19,23 +21,33 @@ class Installer implements Setup\SampleData\InstallerInterface
1921
*/
2022
protected $bundleProduct;
2123

24+
/**
25+
* @var StoreManagerInterface
26+
*/
27+
private $storeManager;
28+
2229
/**
2330
* @param \Magento\BundleSampleData\Model\Product $bundleProduct
31+
* @param StoreManagerInterface $storeManager
2432
*/
2533
public function __construct(
26-
\Magento\BundleSampleData\Model\Product $bundleProduct
34+
\Magento\BundleSampleData\Model\Product $bundleProduct,
35+
StoreManagerInterface $storeManager = null
2736
) {
2837
$this->bundleProduct = $bundleProduct;
38+
$this->storeManager = $storeManager ?: \Magento\Framework\App\ObjectManager::getInstance()
39+
->get(StoreManagerInterface::class);
2940
}
3041

3142
/**
3243
* {@inheritdoc}
3344
*/
3445
public function install()
3546
{
47+
$this->storeManager->setCurrentStore(Store::DISTRO_STORE_ID);
3648
$this->bundleProduct->install(
3749
['Magento_BundleSampleData::fixtures/yoga_bundle.csv'],
3850
['Magento_BundleSampleData::fixtures/images_yoga_bundle.csv']
3951
);
4052
}
41-
}
53+
}

app/code/Magento/BundleSampleData/composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"php": "~5.6.5|7.0.2|7.0.4|~7.0.6",
66
"magento/module-bundle": "100.2.*",
77
"magento/module-sample-data": "100.2.*",
8-
"magento/module-catalog-sample-data": "100.2.*"
8+
"magento/module-catalog-sample-data": "100.2.*",
9+
"magento/module-store": "100.2.*"
910
},
1011
"type": "magento2-module",
1112
"version": "100.2.0-dev",

app/code/Magento/DownloadableSampleData/Setup/Installer.php

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,36 +6,60 @@
66
namespace Magento\DownloadableSampleData\Setup;
77

88
use Magento\Framework\Setup;
9+
use Magento\CatalogSampleData\Model\Category;
10+
use Magento\CatalogSampleData\Model\Attribute;
11+
use Magento\DownloadableSampleData\Model\Product;
12+
use Magento\Store\Model\StoreManagerInterface;
13+
use Magento\Store\Model\Store;
914

1015
class Installer implements Setup\SampleData\InstallerInterface
1116
{
1217
/**
13-
* Setup class for products
14-
*
15-
* @var \Magento\DownloadableSampleData\Model\Product
18+
* @var \Magento\CatalogSampleData\Model\Category
1619
*/
17-
protected $productSetup;
20+
protected $category;
1821

1922
/**
20-
* @param \Magento\CatalogSampleData\Model\Category $category
21-
* @param \Magento\CatalogSampleData\Model\Attribute $attribute
22-
* @param \Magento\DownloadableSampleData\Model\Product $product
23+
* @var Attribute
24+
*/
25+
private $attribute;
26+
27+
/**
28+
* @var Product
29+
*/
30+
private $downloadableProduct;
31+
32+
/**
33+
* @var StoreManagerInterface
34+
*/
35+
private $storeManager;
36+
37+
/**
38+
* @param Category $category
39+
* @param Attribute $attribute
40+
* @param Product $product
41+
* @param StoreManagerInterface $storeManager
2342
*/
2443
public function __construct(
25-
\Magento\CatalogSampleData\Model\Category $category,
26-
\Magento\CatalogSampleData\Model\Attribute $attribute,
27-
\Magento\DownloadableSampleData\Model\Product $product
44+
Category $category,
45+
Attribute $attribute,
46+
Product $product,
47+
StoreManagerInterface $storeManager = null
2848
) {
2949
$this->category = $category;
3050
$this->attribute = $attribute;
3151
$this->downloadableProduct = $product;
52+
$this->storeManager = $storeManager ?: \Magento\Framework\App\ObjectManager::getInstance()
53+
->get(StoreManagerInterface::class);
3254
}
3355

3456
/**
3557
* {@inheritdoc}
3658
*/
3759
public function install()
3860
{
61+
$this->storeManager->setCurrentStore(Store::DISTRO_STORE_ID);
62+
3963
$this->attribute->install(['Magento_DownloadableSampleData::fixtures/attributes.csv']);
4064
$this->category->install(['Magento_DownloadableSampleData::fixtures/categories.csv']);
4165
$this->downloadableProduct->install(
@@ -44,4 +68,4 @@ public function install()
4468
['Magento_DownloadableSampleData::fixtures/downloadable_data_training_video_download.csv']
4569
);
4670
}
47-
}
71+
}

app/code/Magento/DownloadableSampleData/composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
"magento/module-sample-data": "100.2.*",
77
"magento/module-catalog-sample-data": "100.2.*",
88
"magento/module-downloadable": "100.2.*",
9-
"magento/sample-data-media": "100.2.*"
9+
"magento/sample-data-media": "100.2.*",
10+
"magento/module-store": "100.2.*"
1011
},
1112
"type": "magento2-module",
1213
"version": "100.2.0-dev",

app/code/Magento/GroupedProductSampleData/Setup/Installer.php

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
namespace Magento\GroupedProductSampleData\Setup;
77

88
use Magento\Framework\Setup;
9+
use Magento\Store\Model\StoreManagerInterface;
10+
use Magento\Store\Model\Store;
911

1012
class Installer implements Setup\SampleData\InstallerInterface
1113
{
@@ -16,21 +18,33 @@ class Installer implements Setup\SampleData\InstallerInterface
1618
*/
1719
protected $groupedProduct;
1820

21+
/**
22+
* @var StoreManagerInterface
23+
*/
24+
private $storeManager;
25+
1926
/**
2027
* @param \Magento\GroupedProductSampleData\Model\Product $groupedProduct
28+
* @param StoreManagerInterface $storeManager
2129
*/
22-
public function __construct(\Magento\GroupedProductSampleData\Model\Product $groupedProduct) {
30+
public function __construct(
31+
\Magento\GroupedProductSampleData\Model\Product $groupedProduct,
32+
StoreManagerInterface $storeManager = null
33+
) {
2334
$this->groupedProduct = $groupedProduct;
35+
$this->storeManager = $storeManager ?: \Magento\Framework\App\ObjectManager::getInstance()
36+
->get(StoreManagerInterface::class);
2437
}
2538

2639
/**
2740
* {@inheritdoc}
2841
*/
2942
public function install()
3043
{
44+
$this->storeManager->setCurrentStore(Store::DISTRO_STORE_ID);
3145
$this->groupedProduct->install(
3246
['Magento_GroupedProductSampleData::fixtures/yoga_grouped.csv'],
3347
['Magento_GroupedProductSampleData::fixtures/images_yoga_grouped.csv']
3448
);
3549
}
36-
}
50+
}

app/code/Magento/GroupedProductSampleData/composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"php": "~5.6.5|7.0.2|7.0.4|~7.0.6",
66
"magento/module-sample-data": "100.2.*",
77
"magento/module-catalog-sample-data": "100.2.*",
8-
"magento/module-grouped-product": "100.2.*"
8+
"magento/module-grouped-product": "100.2.*",
9+
"magento/module-store": "100.2.*"
910
},
1011
"type": "magento2-module",
1112
"version": "100.2.0-dev",

0 commit comments

Comments
 (0)