Skip to content

Commit c7b224a

Browse files
committed
MAGETWO-69587: Fix issue #6999: Configurable attribute cache was never hit #9809
- Merge Pull Request #9809 from thlassche/magento2:2.1-develop
2 parents 8a84178 + b7486e6 commit c7b224a

File tree

33 files changed

+275
-72
lines changed

33 files changed

+275
-72
lines changed

app/code/Magento/Config/Model/Config/Backend/Email/Logo.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
*/
1212
namespace Magento\Config\Model\Config\Backend\Email;
1313

14+
/**
15+
* @deprecated
16+
*/
1417
class Logo extends \Magento\Config\Model\Config\Backend\Image
1518
{
1619
/**

app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Magento\Catalog\Api\ProductRepositoryInterface;
1111
use Magento\Catalog\Model\Config;
1212
use Magento\Catalog\Model\Product;
13+
use Magento\Catalog\Model\Product\Gallery\ReadHandler as GalleryReadHandler;
1314
use Magento\CatalogInventory\Api\StockRegistryInterface;
1415
use Magento\CatalogInventory\Model\Stock\Status;
1516
use Magento\ConfigurableProduct\Model\Product\Type\Collection\SalableProcessor;
@@ -18,7 +19,6 @@
1819
use Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface;
1920
use Magento\Framework\App\ObjectManager;
2021
use Magento\Framework\EntityManager\MetadataPool;
21-
use Magento\Catalog\Model\Product\Gallery\ReadHandler as GalleryReadHandler;
2222

2323
/**
2424
* Configurable product type implementation
@@ -484,8 +484,11 @@ public function getConfigurableAttributes($product)
484484
*/
485485
protected function hasCacheData($configurableAttributes)
486486
{
487-
$configurableAttributes = $configurableAttributes ?: unserialize($configurableAttributes);
488-
if (is_array($configurableAttributes) && count($configurableAttributes)) {
487+
if ($configurableAttributes) {
488+
$configurableAttributes = unserialize($configurableAttributes);
489+
}
490+
$isTraversable = (is_array($configurableAttributes) || $configurableAttributes instanceof \Traversable);
491+
if ($isTraversable && count($configurableAttributes)) {
489492
foreach ($configurableAttributes as $attribute) {
490493
/** @var \Magento\ConfigurableProduct\Model\Product\Type\Configurable\Attribute $attribute */
491494
if ($attribute->getData('options')) {

app/code/Magento/Customer/etc/adminhtml/system.xml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,19 @@
176176
<frontend_class>required-entry validate-digits</frontend_class>
177177
</field>
178178
</group>
179+
<group id="account_information" translate="label" type="text" sortOrder="35" showInDefault="1" showInWebsite="1" showInStore="1">
180+
<label>Account Information Options</label>
181+
<field id="change_email_template" translate="label comment" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
182+
<label>Change Email Template</label>
183+
<comment>Email template chosen based on theme fallback when "Default" option is selected.</comment>
184+
<source_model>Magento\Config\Model\Config\Source\Email\Template</source_model>
185+
</field>
186+
<field id="change_email_and_password_template" translate="label comment" type="select" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
187+
<label>Change Email and Password Template</label>
188+
<comment>Email template chosen based on theme fallback when "Default" option is selected.</comment>
189+
<source_model>Magento\Config\Model\Config\Source\Email\Template</source_model>
190+
</field>
191+
</group>
179192
<group id="address" translate="label" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="1">
180193
<label>Name and Address Options</label>
181194
<field id="street_lines" translate="label comment" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="0" canRestore="1">

app/code/Magento/Email/Model/AbstractTemplate.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ protected function getLogoUrl($store)
389389
$store
390390
);
391391
if ($fileName) {
392-
$uploadDir = \Magento\Config\Model\Config\Backend\Email\Logo::UPLOAD_DIR;
392+
$uploadDir = \Magento\Email\Model\Design\Backend\Logo::UPLOAD_DIR;
393393
$mediaDirectory = $this->filesystem->getDirectoryRead(DirectoryList::MEDIA);
394394
if ($mediaDirectory->isFile($uploadDir . '/' . $fileName)) {
395395
return $this->storeManager->getStore()->getBaseUrl(
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
/**
3+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Email\Model\Design\Backend;
7+
8+
use Magento\Theme\Model\Design\Backend\Logo as DesignLogo;
9+
10+
class Logo extends DesignLogo
11+
{
12+
/**
13+
* The tail part of directory path for uploading
14+
*/
15+
const UPLOAD_DIR = 'email/logo';
16+
17+
/**
18+
* Upload max file size in kilobytes
19+
*
20+
* @var int
21+
*/
22+
protected $maxFileSize = 2048;
23+
24+
/**
25+
* Getter for allowed extensions of uploaded files
26+
*
27+
* @return string[]
28+
*/
29+
public function getAllowedExtensions()
30+
{
31+
return ['jpg', 'jpeg', 'gif', 'png'];
32+
}
33+
}

app/code/Magento/Email/composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"description": "N/A",
44
"require": {
55
"php": "~5.6.5|7.0.2|7.0.4|~7.0.6",
6+
"magento/module-theme": "100.1.*",
67
"magento/module-config": "100.1.*",
78
"magento/module-store": "100.1.*",
89
"magento/module-cms": "101.0.*",

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
<item name="email_logo" xsi:type="array">
2828
<item name="path" xsi:type="string">design/email/logo</item>
2929
<item name="fieldset" xsi:type="string">other_settings/email</item>
30-
<item name="backend_model" xsi:type="string">Magento\Theme\Model\Design\Backend\Logo</item>
30+
<item name="backend_model" xsi:type="string">Magento\Email\Model\Design\Backend\Logo</item>
3131
<item name="base_url" xsi:type="array">
3232
<item name="type" xsi:type="string">media</item>
3333
<item name="scope_info" xsi:type="string">1</item>

app/code/Magento/Quote/Model/Cart/CartTotalRepository.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use Magento\Framework\Api\DataObjectHelper;
1313
use Magento\Quote\Model\Cart\Totals\ItemConverter;
1414
use Magento\Quote\Api\CouponManagementInterface;
15+
use Magento\Framework\Api\ExtensibleDataInterface;
1516

1617
/**
1718
* Cart totals data object.
@@ -94,6 +95,7 @@ public function get($cartId)
9495
$addressTotalsData = $quote->getShippingAddress()->getData();
9596
$addressTotals = $quote->getShippingAddress()->getTotals();
9697
}
98+
unset($addressTotalsData[ExtensibleDataInterface::EXTENSION_ATTRIBUTES_KEY]);
9799

98100
/** @var \Magento\Quote\Api\Data\TotalsInterface $quoteTotals */
99101
$quoteTotals = $this->totalsFactory->create();

app/code/Magento/Reports/view/adminhtml/layout/reports_report_product_exportlowstockcsv.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
99
<update handle="reports_report_product_lowstock_grid"/>
1010
<body>
11-
<container name="adminhtml.block.report.product.lowstock.grid.container" label="Export CSV"/>
11+
<block class="Magento\Backend\Block\Widget\Grid\Container" name="adminhtml.report.grid.container" template="Magento_Backend::widget/grid/container/empty.phtml"/>
1212
</body>
1313
</page>

app/code/Magento/Reports/view/adminhtml/layout/reports_report_product_exportlowstockexcel.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
99
<update handle="reports_report_product_lowstock_grid"/>
1010
<body>
11-
<container name="adminhtml.block.report.product.lowstock.grid.container" label="Excel XML"/>
11+
<block class="Magento\Backend\Block\Widget\Grid\Container" name="adminhtml.report.grid.container" template="Magento_Backend::widget/grid/container/empty.phtml"/>
1212
</body>
1313
</page>

app/code/Magento/Theme/Model/Design/Backend/Logo.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class Logo extends Image
2121
*/
2222
protected function _getUploadDir()
2323
{
24-
return $this->_mediaDirectory->getRelativePath($this->_appendScopeInfo(self::UPLOAD_DIR));
24+
return $this->_mediaDirectory->getRelativePath($this->_appendScopeInfo(static::UPLOAD_DIR));
2525
}
2626

2727
/**

app/code/Magento/Webapi/Model/AbstractSchemaGenerator.php

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -65,22 +65,13 @@ public function __construct(
6565
}
6666

6767
/**
68-
* Retrieve a list of services visible to current user.
68+
* Retrieve a list of all services.
6969
*
7070
* @return string[]
7171
*/
7272
public function getListOfServices()
7373
{
74-
$listOfAllowedServices = [];
75-
foreach ($this->serviceMetadata->getServicesConfig() as $serviceName => $service) {
76-
foreach ($service[ServiceMetadata::KEY_SERVICE_METHODS] as $method) {
77-
if ($this->authorization->isAllowed($method[ServiceMetadata::KEY_ACL_RESOURCES])) {
78-
$listOfAllowedServices[] = $serviceName;
79-
break;
80-
}
81-
}
82-
}
83-
return $listOfAllowedServices;
74+
return array_keys($this->serviceMetadata->getServicesConfig());
8475
}
8576

8677
/**

app/code/Magento/Webapi/Model/Rest/Swagger/Generator.php

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,18 @@
1313
use Magento\Webapi\Model\Rest\SwaggerFactory;
1414
use Magento\Framework\Webapi\Authorization;
1515
use Magento\Framework\Webapi\Exception as WebapiException;
16-
use Magento\Framework\Exception\AuthenticationException;
17-
use Magento\Framework\Exception\AuthorizationException;
18-
use Magento\Framework\Exception\LocalizedException;
19-
use Magento\Framework\Exception\NoSuchEntityException;
20-
use Magento\Framework\Phrase;
2116
use Magento\Framework\App\ProductMetadataInterface;
2217
use \Magento\Framework\Api\SimpleDataObjectConverter;
18+
use Magento\Webapi\Model\ServiceMetadata;
2319

2420
/**
2521
* REST Swagger schema generator.
2622
*
2723
* Generate REST API description in a format of JSON document,
2824
* compliant with {@link https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md Swagger specification}
25+
*
26+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
27+
* @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
2928
*/
3029
class Generator extends AbstractSchemaGenerator
3130
{
@@ -902,4 +901,23 @@ private function generateMethodExceptionErrorResponses($exceptionClass, $respons
902901

903902
return $responses;
904903
}
904+
905+
/**
906+
* Retrieve a list of services visible to current user.
907+
*
908+
* @return string[]
909+
*/
910+
public function getListOfServices()
911+
{
912+
$listOfAllowedServices = [];
913+
foreach ($this->serviceMetadata->getServicesConfig() as $serviceName => $service) {
914+
foreach ($service[ServiceMetadata::KEY_SERVICE_METHODS] as $method) {
915+
if ($this->authorization->isAllowed($method[ServiceMetadata::KEY_ACL_RESOURCES])) {
916+
$listOfAllowedServices[] = $serviceName;
917+
break;
918+
}
919+
}
920+
}
921+
return $listOfAllowedServices;
922+
}
905923
}

app/code/Magento/Wishlist/Pricing/ConfiguredPrice/ConfigurableProduct.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,12 @@ class ConfigurableProduct extends FinalPrice implements ConfiguredPriceInterface
2121
*/
2222
public function getValue()
2323
{
24-
$result = 0.;
2524
/** @var \Magento\Wishlist\Model\Item\Option $customOption */
2625
$customOption = $this->getProduct()->getCustomOption('simple_product');
27-
if ($customOption) {
28-
/** @var \Magento\Framework\Pricing\PriceInfoInterface $priceInfo */
29-
$priceInfo = $customOption->getProduct()->getPriceInfo();
30-
$result = $priceInfo->getPrice(self::PRICE_CODE)->getValue();
31-
}
32-
return max(0, $result);
26+
$product = $customOption ? $customOption->getProduct() : $this->getProduct();
27+
$price = $product->getPriceInfo()->getPrice(self::PRICE_CODE)->getValue();
28+
29+
return max(0, $price);
3330
}
3431

3532
/**

app/code/Magento/Wishlist/Test/Unit/Pricing/ConfiguredPrice/ConfigurableProductTest.php

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,36 +5,30 @@
55
*/
66
namespace Magento\Wishlist\Test\Unit\Pricing\ConfiguredPrice;
77

8-
use Magento\Framework\Pricing\Adjustment\CalculatorInterface;
9-
use Magento\Framework\Pricing\PriceCurrencyInterface;
10-
use Magento\Framework\Pricing\PriceInfoInterface;
11-
use Magento\Framework\Pricing\SaleableInterface;
12-
use Magento\Wishlist\Pricing\ConfiguredPrice\ConfigurableProduct;
13-
148
class ConfigurableProductTest extends \PHPUnit_Framework_TestCase
159
{
1610
/**
17-
* @var SaleableInterface|\PHPUnit_Framework_MockObject_MockObject
11+
* @var \Magento\Framework\Pricing\SaleableInterface|\PHPUnit_Framework_MockObject_MockObject
1812
*/
1913
private $saleableItem;
2014

2115
/**
22-
* @var CalculatorInterface|\PHPUnit_Framework_MockObject_MockObject
16+
* @var \Magento\Framework\Pricing\Adjustment\CalculatorInterface|\PHPUnit_Framework_MockObject_MockObject
2317
*/
2418
private $calculator;
2519

2620
/**
27-
* @var PriceCurrencyInterface|\PHPUnit_Framework_MockObject_MockObject
21+
* @var \Magento\Framework\Pricing\PriceCurrencyInterface|\PHPUnit_Framework_MockObject_MockObject
2822
*/
2923
private $priceCurrency;
3024

3125
/**
32-
* @var ConfigurableProduct
26+
* @var \Magento\Wishlist\Pricing\ConfiguredPrice\ConfigurableProduct
3327
*/
3428
private $model;
3529

3630
/**
37-
* @var PriceInfoInterface|\PHPUnit_Framework_MockObject_MockObject
31+
* @var \Magento\Framework\Pricing\PriceInfoInterface|\PHPUnit_Framework_MockObject_MockObject
3832
*/
3933
private $priceInfoMock;
4034

@@ -49,17 +43,14 @@ protected function setUp()
4943
'getCustomOption',
5044
])
5145
->getMockForAbstractClass();
52-
$this->saleableItem->expects($this->once())
53-
->method('getPriceInfo')
54-
->willReturn($this->priceInfoMock);
5546

5647
$this->calculator = $this->getMockBuilder('Magento\Framework\Pricing\Adjustment\CalculatorInterface')
5748
->getMockForAbstractClass();
5849

5950
$this->priceCurrency = $this->getMockBuilder('Magento\Framework\Pricing\PriceCurrencyInterface')
6051
->getMockForAbstractClass();
6152

62-
$this->model = new ConfigurableProduct(
53+
$this->model = new \Magento\Wishlist\Pricing\ConfiguredPrice\ConfigurableProduct(
6354
$this->saleableItem,
6455
null,
6556
$this->calculator,
@@ -82,7 +73,7 @@ public function testGetValue()
8273
->getMock();
8374
$this->priceInfoMock->expects($this->once())
8475
->method('getPrice')
85-
->with(ConfigurableProduct::PRICE_CODE)
76+
->with(\Magento\Wishlist\Pricing\ConfiguredPrice\ConfigurableProduct::PRICE_CODE)
8677
->willReturn($priceMock);
8778

8879
$productMock = $this->getMockBuilder('Magento\Catalog\Model\Product')
@@ -109,11 +100,28 @@ public function testGetValue()
109100

110101
public function testGetValueWithNoCustomOption()
111102
{
103+
$priceValue = 100;
104+
105+
$priceMock = $this->getMockBuilder(\Magento\Framework\Pricing\Price\PriceInterface::class)
106+
->getMockForAbstractClass();
107+
$priceMock->expects($this->once())
108+
->method('getValue')
109+
->willReturn($priceValue);
110+
112111
$this->saleableItem->expects($this->once())
113112
->method('getCustomOption')
114113
->with('simple_product')
115114
->willReturn(null);
116115

117-
$this->assertEquals(0, $this->model->getValue());
116+
$this->saleableItem->expects($this->once())
117+
->method('getPriceInfo')
118+
->willReturn($this->priceInfoMock);
119+
120+
$this->priceInfoMock->expects($this->once())
121+
->method('getPrice')
122+
->with(\Magento\Wishlist\Pricing\ConfiguredPrice\ConfigurableProduct::PRICE_CODE)
123+
->willReturn($priceMock);
124+
125+
$this->assertEquals(100, $this->model->getValue());
118126
}
119127
}

0 commit comments

Comments
 (0)