Skip to content

Commit 1f52147

Browse files
committed
Merge pull request #402 from magento-dragons/S82
[DRAGONS] BugFix(S82)
2 parents 67e77fe + ef56af4 commit 1f52147

File tree

128 files changed

+3409
-937
lines changed

Some content is hidden

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

128 files changed

+3409
-937
lines changed

app/code/Magento/Bundle/Controller/Adminhtml/Product/Initialization/Helper/Plugin/Bundle.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ protected function processBundleOptionsData(\Magento\Catalog\Model\Product $prod
130130
if ((bool)$optionData['delete']) {
131131
continue;
132132
}
133+
133134
$option = $this->optionFactory->create(['data' => $optionData]);
134135
$option->setSku($product->getSku());
135136
$option->setOptionId(null);

app/code/Magento/Bundle/Model/ResourceModel/Indexer/Stock.php

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -158,20 +158,7 @@ protected function _getStockStatusSelect($entityIds = null, $usePrimaryTable = f
158158
);
159159
$this->_addAttributeToSelect($select, 'status', "e.$linkField", 'cs.store_id', $condition);
160160

161-
if ($this->_isManageStock()) {
162-
$statusExpr = $connection->getCheckSql(
163-
'cisi.use_config_manage_stock = 0 AND cisi.manage_stock = 0',
164-
'1',
165-
'cisi.is_in_stock'
166-
);
167-
} else {
168-
$statusExpr = $connection->getCheckSql(
169-
'cisi.use_config_manage_stock = 0 AND cisi.manage_stock = 1',
170-
'cisi.is_in_stock',
171-
'1'
172-
);
173-
}
174-
161+
$statusExpr = $this->getStatusExpression($connection);
175162
$select->columns(
176163
[
177164
'status' => $connection->getLeastSql(

app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Action/Attribute/Tab/Inventory.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ class Inventory extends \Magento\Backend\Block\Widget implements \Magento\Backen
2020
*/
2121
protected $stockConfiguration;
2222

23+
/**
24+
* @var array
25+
*/
26+
protected $disabledFields = [];
27+
2328
/**
2429
* @param \Magento\Backend\Block\Template\Context $context
2530
* @param \Magento\CatalogInventory\Model\Source\Backorders $backorders
@@ -112,4 +117,14 @@ public function isHidden()
112117
{
113118
return false;
114119
}
120+
121+
/**
122+
* @param string $fieldName
123+
* @return bool
124+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
125+
*/
126+
public function isAvailable($fieldName)
127+
{
128+
return true;
129+
}
115130
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Catalog\Block\Category\Plugin;
8+
9+
use Magento\Catalog\Model\Product;
10+
use Magento\Customer\Model\Session;
11+
use Magento\Framework\App\ScopeResolverInterface;
12+
use Magento\Framework\Pricing\PriceCurrencyInterface;
13+
use Magento\Framework\Pricing\Render\PriceBox;
14+
use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
15+
16+
class PriceBoxTags
17+
{
18+
/**
19+
* @var TimezoneInterface
20+
*/
21+
protected $dateTime;
22+
23+
/**
24+
* @var \Magento\Customer\Model\Session
25+
*/
26+
protected $customerSession;
27+
28+
/**
29+
* @var PriceCurrencyInterface
30+
*/
31+
private $priceCurrency;
32+
33+
/**
34+
* @var ScopeResolverInterface
35+
*/
36+
private $scopeResolver;
37+
38+
/**
39+
* PriceBoxTags constructor.
40+
* @param PriceCurrencyInterface $priceCurrency
41+
* @param TimezoneInterface $dateTime
42+
* @param ScopeResolverInterface $scopeResolver
43+
* @param Session $customerSession
44+
*/
45+
public function __construct(
46+
PriceCurrencyInterface $priceCurrency,
47+
TimezoneInterface $dateTime,
48+
ScopeResolverInterface $scopeResolver,
49+
Session $customerSession
50+
) {
51+
$this->dateTime = $dateTime;
52+
$this->customerSession = $customerSession;
53+
$this->priceCurrency = $priceCurrency;
54+
$this->scopeResolver = $scopeResolver;
55+
}
56+
57+
/**
58+
* @param PriceBox $subject
59+
* @param string $result
60+
* @return string
61+
*
62+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
63+
*/
64+
public function afterGetCacheKey(PriceBox $subject, $result)
65+
{
66+
return implode(
67+
'-',
68+
[
69+
$result,
70+
$this->priceCurrency->getCurrencySymbol(),
71+
$this->dateTime->scopeDate($this->scopeResolver->getScope()->getId())->format('Ymd'),
72+
$this->scopeResolver->getScope()->getId(),
73+
$this->customerSession->getCustomerGroupId(),
74+
]
75+
);
76+
}
77+
}

app/code/Magento/Catalog/Controller/Category/View.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,13 +172,15 @@ public function execute()
172172
if ($settings->getPageLayout()) {
173173
$page->getConfig()->setPageLayout($settings->getPageLayout());
174174
}
175+
176+
$hasChildren = $category->hasChildren();
175177
if ($category->getIsAnchor()) {
176-
$type = $category->hasChildren() ? 'layered' : 'layered_without_children';
178+
$type = $hasChildren ? 'layered' : 'layered_without_children';
177179
} else {
178-
$type = $category->hasChildren() ? 'default' : 'default_without_children';
180+
$type = $hasChildren ? 'default' : 'default_without_children';
179181
}
180182

181-
if (!$category->hasChildren()) {
183+
if (!$hasChildren) {
182184
// Two levels removed from parent. Need to add default page type.
183185
$parentType = strtok($type, '_');
184186
$page->addPageLayoutHandles(['type' => $parentType]);

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1115,7 +1115,10 @@ public function getIdentities()
11151115
$identities = [
11161116
self::CACHE_TAG . '_' . $this->getId(),
11171117
];
1118-
if ($this->hasDataChanges() || $this->isDeleted()) {
1118+
if (!$this->getId() || $this->hasDataChanges()
1119+
|| $this->isDeleted() || $this->dataHasChangedFor(self::KEY_INCLUDE_IN_MENU)
1120+
) {
1121+
$identities[] = self::CACHE_TAG;
11191122
$identities[] = Product::CACHE_PRODUCT_CATEGORY_TAG . '_' . $this->getId();
11201123
}
11211124
return $identities;

app/code/Magento/Catalog/Model/Category/DataProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ public function getAttributesMeta(Type $entityType)
253253
$meta[$code]['validation'] = $rules;
254254
}
255255

256-
$meta[$code]['scope_label'] = $this->getScopeLabel($attribute);
256+
$meta[$code]['scopeLabel'] = $this->getScopeLabel($attribute);
257257
$meta[$code]['componentType'] = Field::NAME;
258258
}
259259

app/code/Magento/Catalog/Model/Layer/Filter/AbstractFilter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ protected function getOptionText($optionId)
376376
*/
377377
protected function getAttributeIsFilterable($attribute)
378378
{
379-
return $attribute->getIsFilterable();
379+
return (int)$attribute->getIsFilterable();
380380
}
381381

382382
/**

app/code/Magento/Catalog/Model/Product/Attribute/Backend/GroupPrice/AbstractGroupPrice.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ public function validate($object)
166166
if (!empty($priceRow['delete'])) {
167167
continue;
168168
}
169-
$compare = join(
169+
$compare = implode(
170170
'-',
171171
array_merge(
172172
[$priceRow['website_id'], $priceRow['cust_group']],
@@ -191,7 +191,7 @@ public function validate($object)
191191
if ($origPrices) {
192192
foreach ($origPrices as $price) {
193193
if ($price['website_id'] == 0) {
194-
$compare = join(
194+
$compare = implode(
195195
'-',
196196
array_merge(
197197
[$price['website_id'], $price['cust_group']],
@@ -215,7 +215,7 @@ public function validate($object)
215215
continue;
216216
}
217217

218-
$globalCompare = join(
218+
$globalCompare = implode(
219219
'-',
220220
array_merge([0, $priceRow['cust_group']], $this->_getAdditionalUniqueFields($priceRow))
221221
);
@@ -243,7 +243,7 @@ public function preparePriceData(array $priceData, $productTypeId, $websiteId)
243243
$data = [];
244244
$price = $this->_catalogProductType->priceFactory($productTypeId);
245245
foreach ($priceData as $v) {
246-
$key = join('-', array_merge([$v['cust_group']], $this->_getAdditionalUniqueFields($v)));
246+
$key = implode('-', array_merge([$v['cust_group']], $this->_getAdditionalUniqueFields($v)));
247247
if ($v['website_id'] == $websiteId) {
248248
$data[$key] = $v;
249249
$data[$key]['website_price'] = $v['price'];
@@ -316,7 +316,7 @@ public function afterSave($object)
316316
$isGlobal = $this->getAttribute()->isScopeGlobal() || $websiteId == 0;
317317

318318
$priceRows = $object->getData($this->getAttribute()->getName());
319-
if ($priceRows === null) {
319+
if (null === $priceRows) {
320320
return $this;
321321
}
322322

@@ -330,7 +330,7 @@ public function afterSave($object)
330330
}
331331
foreach ($origPrices as $data) {
332332
if ($data['website_id'] > 0 || $data['website_id'] == '0' && $isGlobal) {
333-
$key = join(
333+
$key = implode(
334334
'-',
335335
array_merge(
336336
[$data['website_id'], $data['cust_group']],
@@ -361,7 +361,7 @@ public function afterSave($object)
361361
continue;
362362
}
363363

364-
$key = join(
364+
$key = implode(
365365
'-',
366366
array_merge([$data['website_id'], $data['cust_group']], $this->_getAdditionalUniqueFields($data))
367367
);

app/code/Magento/Catalog/Model/Product/Attribute/Repository.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ class Repository implements \Magento\Catalog\Api\ProductAttributeRepositoryInter
4949
*/
5050
protected $searchCriteriaBuilder;
5151

52+
/**
53+
* @var \Magento\Catalog\Api\ProductAttributeOptionManagementInterface
54+
*/
55+
private $optionManagement;
56+
5257
/**
5358
* @param \Magento\Catalog\Model\ResourceModel\Attribute $attributeResource
5459
* @param \Magento\Catalog\Helper\Product $productHelper
@@ -57,6 +62,7 @@ class Repository implements \Magento\Catalog\Api\ProductAttributeRepositoryInter
5762
* @param \Magento\Eav\Model\Config $eavConfig
5863
* @param \Magento\Eav\Model\Adminhtml\System\Config\Source\Inputtype\ValidatorFactory $validatorFactory
5964
* @param \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder
65+
* @param \Magento\Catalog\Api\ProductAttributeOptionManagementInterface $optionManagement
6066
*/
6167
public function __construct(
6268
\Magento\Catalog\Model\ResourceModel\Attribute $attributeResource,
@@ -65,7 +71,8 @@ public function __construct(
6571
\Magento\Eav\Api\AttributeRepositoryInterface $eavAttributeRepository,
6672
\Magento\Eav\Model\Config $eavConfig,
6773
\Magento\Eav\Model\Adminhtml\System\Config\Source\Inputtype\ValidatorFactory $validatorFactory,
68-
\Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder
74+
\Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder,
75+
\Magento\Catalog\Api\ProductAttributeOptionManagementInterface $optionManagement
6976
) {
7077
$this->attributeResource = $attributeResource;
7178
$this->productHelper = $productHelper;
@@ -74,6 +81,7 @@ public function __construct(
7481
$this->eavConfig = $eavConfig;
7582
$this->inputtypeValidatorFactory = $validatorFactory;
7683
$this->searchCriteriaBuilder = $searchCriteriaBuilder;
84+
$this->optionManagement = $optionManagement;
7785
}
7886

7987
/**
@@ -171,7 +179,10 @@ public function save(\Magento\Catalog\Api\Data\ProductAttributeInterface $attrib
171179
$attribute->setIsUserDefined(1);
172180
}
173181
$this->attributeResource->save($attribute);
174-
return $attribute;
182+
foreach ($attribute->getOptions() as $option) {
183+
$this->optionManagement->add($attribute->getAttributeCode(), $option);
184+
}
185+
return $this->get($attribute->getAttributeCode());
175186
}
176187

177188
/**

0 commit comments

Comments
 (0)