Skip to content

Commit aa20e24

Browse files
committed
MTA-4065: Import Advanced Pricing if Incorrect Data
- merge commit
2 parents 6daacb3 + c7fff61 commit aa20e24

File tree

62 files changed

+2201
-306
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+2201
-306
lines changed

README.md

Lines changed: 6 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -3,61 +3,14 @@
33
<h2>Welcome</h2>
44
Welcome to Magento 2 installation! We're glad you chose to install Magento 2, a cutting edge, feature-rich eCommerce solution that gets results.
55

6-
The installation instructions that used to be here are now published on our GitHub site. Use the information on this page to get started or go directly to the <a href="http://devdocs.magento.com/guides/v2.0/install-gde/bk-install-guide.html" target="_blank">guide</a>.
6+
## Magento system requirements
7+
[Magento system requirements](http://devdocs.magento.com/magento-system-requirements.html)
78

8-
<h2>New to Magento? Need some help?</h2>
9-
If you're not sure about the following, you probably need a little help before you start installing the Magento software:
9+
## Install Magento
10+
To install Magento, see either:
1011

11-
* Is the Magento software <a href="http://devdocs.magento.com/guides/v2.0/install-gde/basics/basics_magento-installed.html">installed already</a>?
12-
* What's a <a href="http://devdocs.magento.com/guides/v2.0/install-gde/basics/basics_login.html">terminal, command prompt, or Secure Shell (ssh)</a>?
13-
* Where's my <a href="http://devdocs.magento.com/guides/v2.0/install-gde/basics/basics_login.html">Magento server</a> and how do I access it?
14-
* What's <a href="http://devdocs.magento.com/guides/v2.0/install-gde/basics/basics_software.html">PHP</a>?
15-
* What's <a href="http://devdocs.magento.com/guides/v2.0/install-gde/basics/basics_software.html">Apache</a>?
16-
* What's <a href="http://devdocs.magento.com/guides/v2.0/install-gde/basics/basics_software.html">MySQL</a>?
17-
18-
<h2>Step 1: Verify your prerequisites</h2>
19-
20-
Use the following table to verify you have the correct prerequisites to install the Magento software.
21-
22-
<table>
23-
<tbody>
24-
<tr>
25-
<th>Prerequisite</th>
26-
<th>How to check</th>
27-
<th>For more information</th>
28-
</tr>
29-
<tr>
30-
<td>Apache 2.2 or 2.4</td>
31-
<td>Ubuntu: <code>apache2 -v</code><br>
32-
CentOS: <code>httpd -v</code></td>
33-
<td><a href="http://devdocs.magento.com/guides/v2.0/install-gde/prereq/apache.html">Apache</a></td>
34-
</tr>
35-
<tr>
36-
<td>PHP 5.6.x, 7.0.2, 7.0.4 or 7.0.6</td>
37-
<td><code>php -v</code></td>
38-
<td><a href="http://devdocs.magento.com/guides/v2.0/install-gde/prereq/php-ubuntu.html">PHP Ubuntu</a><br><a href="http://devdocs.magento.com/guides/v2.0/install-gde/prereq/php-centos.html">PHP CentOS</a></td>
39-
</tr>
40-
<tr><td>MySQL 5.6.x</td>
41-
<td><code>mysql -u [root user name] -p</code></td>
42-
<td><a href="http://devdocs.magento.com/guides/v2.0/install-gde/prereq/mysql.html">MySQL</a></td>
43-
</tr>
44-
</tbody>
45-
</table>
46-
47-
<h2>Step 2: Prepare to install</h2>
48-
49-
After verifying your prerequisites, perform the following tasks in order to prepare to install the Magento software.
50-
51-
1. <a href="http://devdocs.magento.com/guides/v2.0/install-gde/install/composer-clone.html#instgde-prereq-compose-install">Install Composer</a>
52-
2. <a href="http://devdocs.magento.com/guides/v2.0/install-gde/install/composer-clone.html#instgde-prereq-compose-clone">Clone the Magento repository</a>
53-
54-
<h2>Step 3: Install and verify the installation</h2>
55-
56-
1. <a href="http://devdocs.magento.com/guides/v2.0/install-gde/install/prepare-install.html">Update installation dependencies</a>
57-
2. Install Magento:
58-
* <a href="http://devdocs.magento.com/guides/v2.0/install-gde/install/install-web.html">Install Magento software using the web interface</a>
59-
* <a href="http://devdocs.magento.com/guides/v2.0/install-gde/install/install-cli.html">Install Magento software using the command line</a>
60-
2. <a href="http://devdocs.magento.com/guides/v2.0/install-gde/install/verify.html">Verify the installation</a>
12+
* [Magento DevBox](https://magento.com/tech-resources/download), the easiest way to get started with Magento.
13+
* [Installation guide](http://devdocs.magento.com/guides/v2.0/install-gde/bk-install-guide.html)
6114

6215
<h2>Contributing to the Magento 2 code base</h2>
6316
Contributions can take the form of new components or features, changes to existing features, tests, documentation (such as developer guides, user guides, examples, or specifications), bug fixes, optimizations, or just good suggestions.

app/code/Magento/Backend/Block/Dashboard/Tab/Products/Viewed.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
*/
66
namespace Magento\Backend\Block\Dashboard\Tab\Products;
77

8+
use Magento\Catalog\Model\Product;
9+
use Magento\Catalog\Pricing\Price\FinalPrice;
10+
811
/**
912
* Adminhtml dashboard most viewed products grid
1013
*
@@ -66,8 +69,14 @@ protected function _prepareCollection()
6669
);
6770

6871
$this->setCollection($collection);
72+
parent::_prepareCollection();
73+
74+
/** @var Product $product */
75+
foreach ($collection as $product) {
76+
$product->setPrice($product->getPriceInfo()->getPrice(FinalPrice::PRICE_CODE)->getValue());
77+
}
6978

70-
return parent::_prepareCollection();
79+
return $this;
7180
}
7281

7382
/**

app/code/Magento/Backend/i18n/en_US.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ Minute,Minute
250250
"JavaScript may be disabled in your browser.","JavaScript may be disabled in your browser."
251251
"To use this website you must first enable JavaScript in your browser.","To use this website you must first enable JavaScript in your browser."
252252
"This is only a demo store. You can browse and place orders, but nothing will be processed.","This is only a demo store. You can browse and place orders, but nothing will be processed."
253-
"Report Bugs","Report Bugs"
253+
"Report a Bug","Report a Bug"
254254
"Store View:","Store View:"
255255
"Stores Configuration","Stores Configuration"
256256
"Please confirm scope switching. All data that hasn\'t been saved will be lost.","Please confirm scope switching. All data that hasn\'t been saved will be lost."

app/code/Magento/Backend/view/adminhtml/templates/page/report.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@
88

99
?>
1010
<?php if ($block->getBugreportUrl()): ?>
11-
<a class="link-report" href="<?php /* @escapeNotVerified */ echo $block->getBugreportUrl(); ?>" id="footer_bug_tracking"><?php /* @escapeNotVerified */ echo __('Report Bugs') ?></a>
11+
<a class="link-report" href="<?php /* @escapeNotVerified */ echo $block->getBugreportUrl(); ?>" id="footer_bug_tracking"><?php /* @escapeNotVerified */ echo __('Report a Bug') ?></a>
1212
<?php endif; ?>

app/code/Magento/Catalog/Model/ProductWebsiteLinkRepository.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function save(ProductWebsiteLinkInterface $productWebsiteLink)
3737
$product = $this->productRepository->get($productWebsiteLink->getSku());
3838
$product->setWebsiteIds(array_merge($product->getWebsiteIds(), [$productWebsiteLink->getWebsiteId()]));
3939
try {
40-
$product->save();
40+
$this->productRepository->save($product);
4141
} catch (\Exception $e) {
4242
throw new CouldNotSaveException(
4343
__(
@@ -68,7 +68,7 @@ public function deleteById($sku, $websiteId)
6868
$product->setWebsiteIds(array_diff($product->getWebsiteIds(), [$websiteId]));
6969

7070
try {
71-
$product->save();
71+
$this->productRepository->save($product);
7272
} catch (\Exception $e) {
7373
throw new CouldNotSaveException(
7474
__(

app/code/Magento/Catalog/Model/ResourceModel/Product/LinkedProductSelectBuilderByBasePrice.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,15 +98,15 @@ public function build($productId)
9898
->limit(1);
9999
$priceSelect = $this->baseSelectProcessor->process($priceSelect);
100100

101-
$priceSelectDefault = clone $priceSelect;
102-
$priceSelectDefault->where('t.store_id = ?', Store::DEFAULT_STORE_ID);
103-
$select[] = $priceSelectDefault;
104-
105101
if (!$this->catalogHelper->isPriceGlobal()) {
106-
$priceSelect->where('t.store_id = ?', $this->storeManager->getStore()->getId());
107-
$select[] = $priceSelect;
102+
$priceSelectStore = clone $priceSelect;
103+
$priceSelectStore->where('t.store_id = ?', $this->storeManager->getStore()->getId());
104+
$selects[] = $priceSelectStore;
108105
}
109106

110-
return $select;
107+
$priceSelect->where('t.store_id = ?', Store::DEFAULT_STORE_ID);
108+
$selects[] = $priceSelect;
109+
110+
return $selects;
111111
}
112112
}

app/code/Magento/Catalog/Model/ResourceModel/Product/LinkedProductSelectBuilderBySpecialPrice.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -142,15 +142,15 @@ public function build($productId)
142142
->limit(1);
143143
$specialPrice = $this->baseSelectProcessor->process($specialPrice);
144144

145-
$specialPriceDefault = clone $specialPrice;
146-
$specialPriceDefault->where('t.store_id = ?', Store::DEFAULT_STORE_ID);
147-
$select[] = $specialPriceDefault;
148-
149145
if (!$this->catalogHelper->isPriceGlobal()) {
150-
$specialPrice->where('t.store_id = ?', $this->storeManager->getStore()->getId());
151-
$select[] = $specialPrice;
146+
$priceSelectStore = clone $specialPrice;
147+
$priceSelectStore->where('t.store_id = ?', $this->storeManager->getStore()->getId());
148+
$selects[] = $priceSelectStore;
152149
}
153150

154-
return $select;
151+
$specialPrice->where('t.store_id = ?', Store::DEFAULT_STORE_ID);
152+
$selects[] = $specialPrice;
153+
154+
return $selects;
155155
}
156156
}

app/code/Magento/Catalog/Model/ResourceModel/Product/LinkedProductSelectBuilderByTierPrice.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,15 @@ public function build($productId)
100100
->limit(1);
101101
$priceSelect = $this->baseSelectProcessor->process($priceSelect);
102102

103-
$priceSelectDefault = clone $priceSelect;
104-
$priceSelectDefault->where('t.website_id = ?', self::DEFAULT_WEBSITE_ID);
105-
$select[] = $priceSelectDefault;
106-
107103
if (!$this->catalogHelper->isPriceGlobal()) {
108-
$priceSelect->where('t.website_id = ?', $this->storeManager->getStore()->getWebsiteId());
109-
$select[] = $priceSelect;
104+
$priceSelectStore = clone $priceSelect;
105+
$priceSelectStore->where('t.website_id = ?', $this->storeManager->getStore()->getWebsiteId());
106+
$selects[] = $priceSelectStore;
110107
}
111108

112-
return $select;
109+
$priceSelect->where('t.website_id = ?', self::DEFAULT_WEBSITE_ID);
110+
$selects[] = $priceSelect;
111+
112+
return $selects;
113113
}
114114
}

app/code/Magento/Catalog/Model/ResourceModel/Product/LinkedProductSelectBuilderComposite.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ public function __construct($linkedProductSelectBuilder)
2626
*/
2727
public function build($productId)
2828
{
29-
$select = [];
29+
$selects = [];
3030
foreach ($this->linkedProductSelectBuilder as $productSelectBuilder) {
31-
$select = array_merge($select, $productSelectBuilder->build($productId));
31+
$selects = array_merge($selects, $productSelectBuilder->build($productId));
3232
}
3333

34-
return $select;
34+
return $selects;
3535
}
3636
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?php
2+
/**
3+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Catalog\Model\ResourceModel\Product\Website;
7+
8+
use Magento\Catalog\Model\ResourceModel\Product\BaseSelectProcessorInterface;
9+
use Magento\Framework\DB\Select;
10+
use Magento\Framework\EntityManager\MetadataPool;
11+
use Magento\Catalog\Api\Data\ProductInterface;
12+
use Magento\Framework\App\ResourceConnection;
13+
use Magento\Store\Model\StoreManagerInterface;
14+
15+
/**
16+
* Filter products that belongs to current website
17+
*/
18+
class SelectProcessor implements BaseSelectProcessorInterface
19+
{
20+
/**
21+
* @var ResourceConnection
22+
*/
23+
private $resource;
24+
25+
/**
26+
* @var MetadataPool
27+
*/
28+
private $metadataPool;
29+
30+
/**
31+
* @var StoreManagerInterface
32+
*/
33+
private $storeManager;
34+
35+
/**
36+
* @param MetadataPool $metadataPool
37+
* @param ResourceConnection $resource
38+
* @param StoreManagerInterface $storeManager
39+
*/
40+
public function __construct(
41+
MetadataPool $metadataPool,
42+
ResourceConnection $resource,
43+
StoreManagerInterface $storeManager
44+
) {
45+
$this->metadataPool = $metadataPool;
46+
$this->resource = $resource;
47+
$this->storeManager = $storeManager;
48+
}
49+
50+
/**
51+
* Joins website-product relation table to filter products that are only in current website
52+
*
53+
* {@inheritdoc}
54+
*/
55+
public function process(Select $select)
56+
{
57+
$linkField = $this->metadataPool->getMetadata(ProductInterface::class)->getLinkField();
58+
$select->joinInner(
59+
['pw' => $this->resource->getTableName('catalog_product_website')],
60+
'pw.product_id = ' . BaseSelectProcessorInterface::PRODUCT_TABLE_ALIAS . '.' . $linkField
61+
. ' AND pw.website_id = ' . $this->storeManager->getWebsite()->getId(),
62+
[]
63+
);
64+
65+
return $select;
66+
}
67+
}

app/code/Magento/Catalog/etc/di.xml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -851,14 +851,26 @@
851851
<type name="Magento\Quote\Model\Quote\Item\ToOrderItem">
852852
<plugin name="copy_quote_files_to_order" type="Magento\Catalog\Model\Plugin\QuoteItemProductOption"/>
853853
</type>
854-
<preference for="Magento\Catalog\Model\ResourceModel\Product\BaseSelectProcessorInterface" type="Magento\Catalog\Model\ResourceModel\Product\CompositeBaseSelectProcessor" />
854+
<preference for="Magento\Catalog\Model\ResourceModel\Product\BaseSelectProcessorInterface" type="Magento\Catalog\Model\ResourceModel\Product\CompositeWithWebsiteProcessor" />
855855
<type name="Magento\Catalog\Model\ResourceModel\Product\CompositeBaseSelectProcessor">
856856
<arguments>
857857
<argument name="baseSelectProcessors" xsi:type="array">
858858
<item name="status" xsi:type="object">Magento\Catalog\Model\ResourceModel\Product\StatusBaseSelectProcessor</item>
859859
</argument>
860860
</arguments>
861861
</type>
862+
<virtualType name="Magento\Catalog\Model\ResourceModel\Product\CompositeWithWebsiteProcessor" type="Magento\Catalog\Model\ResourceModel\Product\CompositeBaseSelectProcessor">
863+
<arguments>
864+
<argument name="baseSelectProcessors" xsi:type="array">
865+
<item name="website" xsi:type="object">Magento\Catalog\Model\ResourceModel\Product\Website\SelectProcessor</item>
866+
</argument>
867+
</arguments>
868+
</virtualType>
869+
<type name="Magento\Catalog\Model\ResourceModel\Product\Indexer\LinkedProductSelectBuilderByIndexPrice">
870+
<arguments>
871+
<argument name="baseSelectProcessor" xsi:type="object">Magento\Catalog\Model\ResourceModel\Product\CompositeBaseSelectProcessor</argument>
872+
</arguments>
873+
</type>
862874
<type name="Magento\Catalog\Model\Product\Price\CostStorage">
863875
<arguments>
864876
<argument name="allowedProductTypes" xsi:type="array">

app/code/Magento/Catalog/view/adminhtml/web/js/components/dynamic-rows-import-custom-options.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,27 @@ define([
5454
if (!data) {
5555
return;
5656
}
57-
data.each(function (item) {
57+
_.each(data, function (item) {
5858
if (!item.options) {
5959
return;
6060
}
61-
item.options.each(function (option) {
61+
_.each(item.options, function (option) {
6262
currentOption = utils.copy(option);
6363

6464
if (currentOption.hasOwnProperty('sort_order')) {
6565
delete currentOption['sort_order'];
6666
}
67-
currentOption['option_id'] = ++maxId;
67+
68+
if (currentOption.hasOwnProperty('option_id')) {
69+
delete currentOption['option_id'];
70+
}
71+
72+
if (currentOption.values.length > 0) {
73+
_.each(currentOption.values, function (optionValue) {
74+
delete optionValue['option_id'];
75+
delete optionValue['option_type_id'];
76+
});
77+
}
6878
options.push(currentOption);
6979
});
7080
});
@@ -73,7 +83,7 @@ define([
7383
return;
7484
}
7585
this.cacheGridData = options;
76-
options.each(function (opt) {
86+
_.each(options, function (opt) {
7787
this.mappingValue(opt);
7888
}, this);
7989

app/code/Magento/Catalog/view/frontend/layout/catalog_product_view.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,11 @@
6767
<block class="Magento\Framework\View\Element\Template" name="product.info.form.options" as="options_container">
6868
<block class="Magento\Catalog\Block\Product\View" name="product.info.options.wrapper" as="product_options_wrapper" template="product/view/options/wrapper.phtml">
6969
<block class="Magento\Catalog\Block\Product\View\Options" name="product.info.options" as="product_options" template="product/view/options.phtml">
70-
<block class="Magento\Catalog\Block\Product\View\Options\Type\DefaultType" as="default" template="product/view/options/type/default.phtml"/>
71-
<block class="Magento\Catalog\Block\Product\View\Options\Type\Text" as="text" template="product/view/options/type/text.phtml"/>
72-
<block class="Magento\Catalog\Block\Product\View\Options\Type\File" as="file" template="product/view/options/type/file.phtml"/>
73-
<block class="Magento\Catalog\Block\Product\View\Options\Type\Select" as="select" template="product/view/options/type/select.phtml"/>
74-
<block class="Magento\Catalog\Block\Product\View\Options\Type\Date" as="date" template="product/view/options/type/date.phtml"/>
70+
<block class="Magento\Catalog\Block\Product\View\Options\Type\DefaultType" name="product.info.options.default" as="default" template="product/view/options/type/default.phtml"/>
71+
<block class="Magento\Catalog\Block\Product\View\Options\Type\Text" name="product.info.options.text" as="text" template="product/view/options/type/text.phtml"/>
72+
<block class="Magento\Catalog\Block\Product\View\Options\Type\File" name="product.info.options.file" as="file" template="product/view/options/type/file.phtml"/>
73+
<block class="Magento\Catalog\Block\Product\View\Options\Type\Select" name="product.info.options.select" as="select" template="product/view/options/type/select.phtml"/>
74+
<block class="Magento\Catalog\Block\Product\View\Options\Type\Date" name="product.info.options.date" as="date" template="product/view/options/type/date.phtml"/>
7575
</block>
7676
<block class="Magento\Framework\View\Element\Html\Calendar" name="html_calendar" as="html_calendar" template="Magento_Theme::js/calendar.phtml"/>
7777
</block>

0 commit comments

Comments
 (0)