Skip to content

Commit 548fec3

Browse files
authored
Merge pull request #1529 from magento-tsg/2.0-develop-pr22
[TSG] Backporting for 2.0 (pr22) (2.0.17)
2 parents 5400465 + 46d2502 commit 548fec3

File tree

148 files changed

+5078
-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.

148 files changed

+5078
-937
lines changed

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
use Magento\Backend\Block\Widget\Form\Generic;
1717
use Magento\Config\Model\Config\Source\Yesno;
1818
use Magento\Eav\Helper\Data;
19+
use Magento\Eav\Block\Adminhtml\Attribute\PropertyLocker;
20+
use Magento\Framework\App\ObjectManager;
1921

2022
class Advanced extends Generic
2123
{
@@ -36,6 +38,13 @@ class Advanced extends Generic
3638
*/
3739
protected $disableScopeChangeList;
3840

41+
/**
42+
* Disable form fields.
43+
*
44+
* @var \Magento\Eav\Block\Adminhtml\Attribute\PropertyLocker PropertyLocker
45+
*/
46+
private $propertyLocker;
47+
3948
/**
4049
* @param \Magento\Backend\Block\Template\Context $context
4150
* @param \Magento\Framework\Registry $registry
@@ -241,6 +250,8 @@ protected function _prepareForm()
241250
$form->getElement('is_global')->setDisabled(1);
242251
}
243252
$this->setForm($form);
253+
$this->getPropertyLocker()->lock($form);
254+
244255
return $this;
245256
}
246257

@@ -264,4 +275,18 @@ private function getAttributeObject()
264275
{
265276
return $this->_coreRegistry->registry('entity_attribute');
266277
}
278+
279+
/**
280+
* Get property locker.
281+
*
282+
* @return PropertyLocker
283+
*/
284+
private function getPropertyLocker()
285+
{
286+
if (null === $this->propertyLocker) {
287+
$this->propertyLocker = ObjectManager::getInstance()->get(PropertyLocker::class);
288+
}
289+
290+
return $this->propertyLocker;
291+
}
267292
}

app/code/Magento/Catalog/Block/Product/View/Gallery.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,13 @@ public function getGalleryImages()
6363
);
6464
$image->setData(
6565
'medium_image_url',
66-
$this->_imageHelper->init($product, 'product_page_image_medium')
67-
->constrainOnly(true)->keepAspectRatio(true)->keepFrame(false)
66+
$this->_imageHelper->init($product, 'product_page_image_medium_no_frame')
6867
->setImageFile($image->getFile())
6968
->getUrl()
7069
);
7170
$image->setData(
7271
'large_image_url',
73-
$this->_imageHelper->init($product, 'product_page_image_large')
74-
->constrainOnly(true)->keepAspectRatio(true)->keepFrame(false)
72+
$this->_imageHelper->init($product, 'product_page_image_large_no_frame')
7573
->setImageFile($image->getFile())
7674
->getUrl()
7775
);

app/code/Magento/Catalog/Helper/Image.php

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -241,28 +241,29 @@ protected function setWatermarkProperties()
241241
{
242242
$this->setWatermark(
243243
$this->scopeConfig->getValue(
244-
"design/watermark/{$this->_getModel()->getDestinationSubdir()}_image",
244+
"design/watermark/{$this->getType()}_image",
245245
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
246246
)
247247
);
248248
$this->setWatermarkImageOpacity(
249249
$this->scopeConfig->getValue(
250-
"design/watermark/{$this->_getModel()->getDestinationSubdir()}_imageOpacity",
250+
"design/watermark/{$this->getType()}_imageOpacity",
251251
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
252252
)
253253
);
254254
$this->setWatermarkPosition(
255255
$this->scopeConfig->getValue(
256-
"design/watermark/{$this->_getModel()->getDestinationSubdir()}_position",
256+
"design/watermark/{$this->getType()}_position",
257257
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
258258
)
259259
);
260260
$this->setWatermarkSize(
261261
$this->scopeConfig->getValue(
262-
"design/watermark/{$this->_getModel()->getDestinationSubdir()}_size",
262+
"design/watermark/{$this->getType()}_size",
263263
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
264264
)
265265
);
266+
266267
return $this;
267268
}
268269

@@ -496,14 +497,14 @@ protected function initBaseFile()
496497
*/
497498
protected function isScheduledActionsAllowed()
498499
{
500+
$isAllowed = true;
499501
$model = $this->_getModel();
500-
if ($model->isBaseFilePlaceholder()
501-
&& $model->getNewFile() === true
502-
|| $model->isCached()
503-
) {
504-
return false;
502+
503+
if ($model->isBaseFilePlaceholder() || $model->isCached()) {
504+
$isAllowed = false;
505505
}
506-
return true;
506+
507+
return $isAllowed;
507508
}
508509

509510
/**

app/code/Magento/Catalog/Model/Product/Attribute/Backend/Media.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,10 @@ public function afterSave($object)
194194
if (!empty($image['removed'])) {
195195
if (!empty($image['value_id']) && !isset($picturesInOtherStores[$image['file']])) {
196196
$recordsToDelete[] = $image['value_id'];
197-
$filesToDelete[] = ltrim($image['file'], '/');
197+
// only delete physical files if they are not used by any other products
198+
if ($this->resourceModel->countImageUses($image['file']) <= 1) {
199+
$filesToDelete[] = ltrim($image['file'], '/');
200+
}
198201
}
199202
continue;
200203
}

0 commit comments

Comments
 (0)