Skip to content

Commit 94ad0af

Browse files
committed
Merge branch 'develop' of github.com:magento/magento2-sample-data into MAGETWO-53293
2 parents ed8cc42 + 897c069 commit 94ad0af

File tree

29 files changed

+125
-44
lines changed

29 files changed

+125
-44
lines changed

app/code/Magento/BundleSampleData/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"magento/module-catalog-sample-data": "100.1.*"
99
},
1010
"type": "magento2-module",
11-
"version": "100.1.0-rc1",
11+
"version": "100.1.0-rc2",
1212
"license": [
1313
"OSL-3.0",
1414
"AFL-3.0"

app/code/Magento/CatalogRuleSampleData/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"magento/module-sample-data": "100.1.*"
88
},
99
"type": "magento2-module",
10-
"version": "100.1.0-rc1",
10+
"version": "100.1.0-rc2",
1111
"license": [
1212
"OSL-3.0",
1313
"AFL-3.0"

app/code/Magento/CatalogRuleSampleData/etc/module.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
99
<module name="Magento_CatalogRuleSampleData" setup_version="2.0.0">
1010
<sequence>
11-
<module name="Magento_CatalogRule"/>
11+
<module name="Magento_CatalogRuleConfigurable"/>
1212
<module name="Magento_SampleData"/>
1313
<module name="Magento_ConfigurableSampleData"/>
1414
</sequence>

app/code/Magento/CatalogSampleData/Model/Attribute.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ public function install(array $fixtures)
132132
$data['backend_model'] = $this->productHelper->getAttributeBackendModelByInputType(
133133
$data['frontend_input']
134134
);
135-
$data += ['is_filterable' => 0, 'is_filterable_in_search' => 0, 'apply_to' => []];
135+
$data += ['is_filterable' => 0, 'is_filterable_in_search' => 0];
136136
$data['backend_type'] = $attribute->getBackendTypeByInput($data['frontend_input']);
137137

138138
$attribute->addData($data);
@@ -149,9 +149,8 @@ public function install(array $fixtures)
149149
$attributeSet = $this->processAttributeSet($setName);
150150
$attributeGroupId = $attributeSet->getDefaultGroupId();
151151

152-
$attribute = $this->attributeFactory->create();
152+
$attribute = $this->attributeFactory->create()->load($attributeId);
153153
$attribute
154-
->setId($attributeId)
155154
->setAttributeGroupId($attributeGroupId)
156155
->setAttributeSetId($attributeSet->getId())
157156
->setEntityTypeId($this->getEntityTypeId())

app/code/Magento/CatalogSampleData/Model/Product/Gallery.php

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
use Magento\Catalog\Model\ProductFactory;
99
use Magento\Catalog\Model\ResourceModel\Product\Gallery as GalleryResource;
1010
use Magento\Framework\Setup\SampleData\Context as SampleDataContext;
11+
use Magento\Framework\App\ObjectManager;
12+
use Magento\Catalog\Api\Data\ProductInterface;
1113

1214
/**
1315
* Class Gallery
@@ -44,6 +46,11 @@ class Gallery
4446
*/
4547
protected $eavConfig;
4648

49+
/**
50+
* @var \Magento\Framework\EntityManager\MetadataPool
51+
*/
52+
private $metadataPool;
53+
4754
/**
4855
* @param SampleDataContext $sampleDataContext
4956
* @param ProductFactory $productFactory
@@ -111,6 +118,8 @@ public function setFixtures(array $fixtures)
111118
*/
112119
protected function storeImage($product, $images)
113120
{
121+
$linkField = $this->getMetadataPool()->getMetadata(ProductInterface::class)->getLinkField();
122+
$productId = $product->getData($linkField);
114123
$baseImage = '';
115124
$i = 1;
116125
$mediaAttribute = $this->eavConfig->getAttribute('catalog_product', 'media_gallery');
@@ -122,20 +131,20 @@ protected function storeImage($product, $images)
122131
if (strpos($image, '_main') !== false) {
123132
$baseImage = $image;
124133
}
134+
125135
$id = $this->galleryResource->insertGallery([
126136
'attribute_id' => $mediaAttribute->getAttributeId(),
127-
'entity_id' => $product->getId(),
128137
'value' => $image,
129138
]);
130139
$this->galleryResource->insertGalleryValueInStore([
131140
'value_id' => $id,
132141
'store_id' => \Magento\Store\Model\Store::DEFAULT_STORE_ID,
133-
'entity_id' => $product->getId(),
142+
$linkField => $productId,
134143
'label' => 'Image',
135144
'position' => $i,
136145
'disables' => 0,
137146
]);
138-
$this->galleryResource->bindValueToEntity($id, $product->getId());
147+
$this->galleryResource->bindValueToEntity($id, $productId);
139148
$i++;
140149
}
141150

@@ -152,12 +161,28 @@ protected function storeImage($product, $images)
152161
$table = $imageAttribute->getBackend()->getTable();
153162
/** @var \Magento\Framework\DB\Adapter\AdapterInterface $adapter*/
154163
$data = [
155-
$attribute->getEntity()->getLinkField() => $product->getId(),
164+
$attribute->getEntity()->getLinkField() => $productId,
156165
'attribute_id' => $attribute->getId(),
157166
'value' => $baseImage,
158167
];
159168
$adapter->insertOnDuplicate($table, $data, ['value']);
160169
}
161170
}
162171
}
172+
173+
/**
174+
* @deprecated
175+
*
176+
* @return \Magento\Framework\EntityManager\MetadataPool|mixed
177+
*/
178+
private function getMetadataPool()
179+
{
180+
if (!($this->metadataPool)) {
181+
return ObjectManager::getInstance()->get(
182+
'\Magento\Framework\EntityManager\MetadataPool'
183+
);
184+
} else {
185+
return $this->metadataPool;
186+
}
187+
}
163188
}

app/code/Magento/CatalogSampleData/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"magento/module-sample-data": "100.1.*"
77
},
88
"type": "magento2-module",
9-
"version": "100.1.0-rc1",
9+
"version": "100.1.0-rc2",
1010
"license": [
1111
"OSL-3.0",
1212
"AFL-3.0"

app/code/Magento/CmsSampleData/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"magento/sample-data-media": "100.1.*"
1010
},
1111
"type": "magento2-module",
12-
"version": "100.1.0-rc1",
12+
"version": "100.1.0-rc2",
1313
"license": [
1414
"OSL-3.0",
1515
"AFL-3.0"

app/code/Magento/ConfigurableSampleData/composer.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@
55
"php": "~5.6.0|7.0.2|~7.0.6",
66
"magento/module-configurable-product": "100.1.*",
77
"magento/module-sample-data": "100.1.*",
8-
"magento/module-product-links-sample-data": "100.1.*",
9-
"magento/module-sales-sample-data": "100.1.*"
8+
"magento/module-product-links-sample-data": "100.1.*"
109
},
1110
"type": "magento2-module",
12-
"version": "100.1.0-rc1",
11+
"version": "100.1.0-rc2",
1312
"license": [
1413
"OSL-3.0",
1514
"AFL-3.0"

app/code/Magento/CustomerSampleData/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"magento/module-sample-data": "100.1.*"
77
},
88
"type": "magento2-module",
9-
"version": "100.1.0-rc1",
9+
"version": "100.1.0-rc2",
1010
"license": [
1111
"OSL-3.0",
1212
"AFL-3.0"

app/code/Magento/DownloadableSampleData/Model/Product/Converter.php

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,25 @@
55
*/
66
namespace Magento\DownloadableSampleData\Model\Product;
77

8+
use Magento\Framework\App\Filesystem\DirectoryList;
9+
use Magento\Framework\App\ObjectManager;
10+
use Magento\Framework\Filesystem;
11+
812
/**
913
* Class Converter
1014
*/
1115
class Converter extends \Magento\CatalogSampleData\Model\Product\Converter
1216
{
17+
/**
18+
* @var \Magento\Downloadable\Api\Data\File\ContentInterfaceFactory
19+
*/
20+
private $fileContentFactory;
21+
22+
/**
23+
* @var \Magento\Framework\Filesystem
24+
*/
25+
private $filesystem;
26+
1327
/**
1428
* Get downloadable data from array
1529
*
@@ -84,7 +98,11 @@ public function formatDownloadableLinkData($linkData)
8498
foreach ($linkItems as $csvRow) {
8599
$linkData[$csvRow] = isset($linkData[$csvRow]) ? $linkData[$csvRow] : '';
86100
}
87-
101+
$directory = $this->getFilesystem()->getDirectoryRead(DirectoryList::MEDIA);
102+
$linkPath = $directory->getAbsolutePath('downloadable/files/links' . $linkData['link_item_file']);
103+
$data = base64_encode(file_get_contents($linkPath));
104+
$content = $this->getFileContent()->setFileData($data)
105+
->setName('luma_background_-_model_against_fence_4_sec_.mp4');
88106
$link = [
89107
'is_delete' => '',
90108
'link_id' => '0',
@@ -95,6 +113,7 @@ public function formatDownloadableLinkData($linkData)
95113
'type' => 'file',
96114
'file' => json_encode([['file' => $linkData['link_item_file'], 'status' => 'old']]),
97115
'sort_order' => '',
116+
'link_file_content' => $content
98117
];
99118

100119
return $link;
@@ -106,6 +125,13 @@ public function formatDownloadableLinkData($linkData)
106125
*/
107126
public function getSamplesInfo()
108127
{
128+
$directory = $this->getFilesystem()->getDirectoryRead(DirectoryList::MEDIA);
129+
$linkPath = $directory->getAbsolutePath(
130+
'downloadable/files/samples/l/u/luma_background_-_model_against_fence_4_sec_.mp4'
131+
);
132+
$data = base64_encode(file_get_contents($linkPath));
133+
$content = $this->getFileContent()->setFileData($data)
134+
->setName('luma_background_-_model_against_fence_4_sec_.mp4');
109135
$sample = [
110136
'is_delete' => '',
111137
'sample_id' => '0',
@@ -115,6 +141,7 @@ public function getSamplesInfo()
115141
]]),
116142
'type' => 'file',
117143
'sort_order' => '',
144+
'sample_file_content' => $content
118145
];
119146

120147
$samples = [];
@@ -125,4 +152,32 @@ public function getSamplesInfo()
125152

126153
return $samples;
127154
}
155+
156+
/**
157+
* @return \Magento\Downloadable\Api\Data\File\ContentInterface
158+
* @deprecated
159+
*/
160+
private function getFileContent()
161+
{
162+
if (!$this->fileContentFactory) {
163+
$this->fileContentFactory = ObjectManager::getInstance()->create(
164+
\Magento\Downloadable\Api\Data\File\ContentInterfaceFactory::class
165+
);
166+
}
167+
return $this->fileContentFactory->create();
168+
}
169+
170+
/**
171+
* @return Filesystem
172+
* @deprecated
173+
*/
174+
private function getFilesystem()
175+
{
176+
if (!$this->filesystem) {
177+
$this->filesystem = ObjectManager::getInstance()->create(
178+
Filesystem::class
179+
);
180+
}
181+
return $this->filesystem;
182+
}
128183
}

0 commit comments

Comments
 (0)