Skip to content

Commit b311c28

Browse files
author
Oleksii Korshenko
committed
Merge pull request magento#20 from magento-nord/develop
[NORD] Bugfixes
2 parents 1af1f48 + 19134d0 commit b311c28

File tree

11 files changed

+105
-24
lines changed

11 files changed

+105
-24
lines changed

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/ConfigurableSampleData/composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
"php": "~5.5.0|~5.6.0|~7.0.0",
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",
1211
"version": "100.1.0-rc1",

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
}

app/code/Magento/SalesSampleData/Model/Order/Processor.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,15 @@ public function createOrder($orderData)
130130
{
131131
$this->setPhraseRenderer();
132132
if (!empty($orderData)) {
133-
$orderCreateModel = $this->processQuote($orderData);
133+
$this->currentSession = $this->sessionQuoteFactory->create();
134134
$customer = $this->customerRepository->get(
135135
$orderData['order']['account']['email'],
136136
$this->storeManager->getWebsite()->getId()
137137
);
138+
$this->currentSession->setCustomerId($customer->getId());
139+
$orderCreateModel = $this->processQuote($orderData);
138140
$orderCreateModel->getQuote()->setCustomer($customer);
139-
$orderCreateModel->getSession()->setCustomerId($customer->getId());
141+
140142
$order = $orderCreateModel->createOrder();
141143
$orderItem = $this->getOrderItemForTransaction($order);
142144
$this->invoiceOrder($orderItem);
@@ -163,7 +165,6 @@ public function createOrder($orderData)
163165
*/
164166
protected function processQuote($data = [])
165167
{
166-
$this->currentSession = $this->sessionQuoteFactory->create();
167168
/** @var \Magento\Sales\Model\AdminOrder\Create $orderCreateModel */
168169
$orderCreateModel = $this->createOrderFactory->create(
169170
['quoteSession' => $this->currentSession]
@@ -173,6 +174,7 @@ protected function processQuote($data = [])
173174
$orderCreateModel->setShippingAsBilling(1);
174175
$orderCreateModel->addProducts($data['add_products']);
175176
$orderCreateModel->getQuote()->getShippingAddress()->unsetData('cached_items_all');
177+
$orderCreateModel->getQuote()->getShippingAddress()->setShippingMethod($data['order']['shipping_method']);
176178
$orderCreateModel->getQuote()->setTotalsCollectedFlag(false);
177179
$orderCreateModel->collectShippingRates();
178180
$orderCreateModel->getQuote()->getPayment()->addData($data['payment'])->setQuote($orderCreateModel->getQuote());

app/code/Magento/SalesSampleData/composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"require": {
55
"php": "~5.5.0|~5.6.0|~7.0.0",
66
"magento/module-sales": "100.1.*",
7-
"magento/module-sample-data": "100.1.*"
7+
"magento/module-sample-data": "100.1.*",
8+
"magento/module-configurable-sample-data": "100.1.*"
89
},
910
"type": "magento2-module",
1011
"version": "100.1.0-rc1",

dev/tests/functional/tests/app/Magento/CustomerSampleData/Test/TestCase/LoginCustomerTest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<data name="customer/data/firstname" xsi:type="string">Veronica</data>
1313
<data name="customer/data/lastname" xsi:type="string">Costello</data>
1414
<data name="customer/data/email" xsi:type="string">[email protected]</data>
15-
<data name="customer/data/password" xsi:type="string">roni_cost@example.com</data>
15+
<data name="customer/data/password" xsi:type="string">roni_cost3@example.com</data>
1616
</variation>
1717
</testCase>
1818
</config>

dev/tests/functional/tests/app/Magento/SalesSampleData/Test/TestCase/CheckoutSalesSampleDataProductEntityTest.xml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,19 @@
1212
<data name="id" xsi:type="string">1</data>
1313
<data name="salesRule" xsi:type="string">active_sales_rule_for_all_groups</data>
1414
<data name="prices" xsi:type="array">
15-
<item name="grandTotal" xsi:type="string">50.00</item>
15+
<item name="grandTotal" xsi:type="string">53.71</item>
1616
</data>
1717
<data name="status" xsi:type="string">Pending</data>
1818
<data name="orderButtonsAvailable" xsi:type="string">Back, Cancel, Hold, Ship, Invoice, Edit</data>
1919
<data name="payment/method" xsi:type="string">checkmo</data>
2020
<data name="checkoutMethod" xsi:type="string">login</data>
21-
<data name="shippingAddress/dataset" xsi:type="string">US_address_1_without_email</data>
2221
<data name="shipping/shipping_service" xsi:type="string">Flat Rate</data>
2322
<data name="shipping/shipping_method" xsi:type="string">Fixed</data>
2423
<data name="configData" xsi:type="string">checkmo</data>
24+
<data name="customer/data/firstname" xsi:type="string">Veronica</data>
25+
<data name="customer/data/lastname" xsi:type="string">Costello</data>
26+
<data name="customer/data/email" xsi:type="string">[email protected]</data>
27+
<data name="customer/data/password" xsi:type="string">[email protected]</data>
2528
<constraint name="Magento\Checkout\Test\Constraint\AssertOrderSuccessPlacedMessage"/>
2629
<constraint name="Magento\Sales\Test\Constraint\AssertOrderInOrdersGridOnFrontend"/>
2730
</variation>

dev/tests/functional/tests/app/Magento/SalesSampleData/Test/etc/testcase.xml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,12 @@
77
-->
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/Magento/Mtf/TestCase/etc/testcase.xsd">
99
<scenario name="CheckoutSalesSampleDataProductEntityTest" firstStep="setupConfiguration">
10-
<step name="setupConfiguration" module="Magento_Config" next="createCustomer"/>
11-
<step name="createCustomer" module="Magento_Customer" next="createProducts"/>
10+
<step name="setupConfiguration" module="Magento_Config" next="loginCustomerOnFrontend"/>
11+
<step name="loginCustomerOnFrontend" module="Magento_Customer" next="createProducts"/>
1212
<step name="createProducts" module="Magento_Catalog" next="addProductsToTheCart"/>
1313
<step name="addProductsToTheCart" module="Magento_Checkout" next="estimateShippingAndTax"/>
1414
<step name="estimateShippingAndTax" module="Magento_Checkout" next="clickProceedToCheckout"/>
15-
<step name="clickProceedToCheckout" module="Magento_Checkout" next="selectCheckoutMethod"/>
16-
<step name="selectCheckoutMethod" module="Magento_Checkout" next="fillShippingAddress"/>
17-
<step name="fillShippingAddress" module="Magento_Checkout" next="fillShippingMethod"/>
15+
<step name="clickProceedToCheckout" module="Magento_Checkout" next="fillShippingMethod"/>
1816
<step name="fillShippingMethod" module="Magento_Checkout" next="selectPaymentMethod"/>
1917
<step name="selectPaymentMethod" module="Magento_Checkout" next="placeOrder"/>
2018
<step name="placeOrder" module="Magento_Checkout"/>

0 commit comments

Comments
 (0)