Skip to content

Commit 481bc3b

Browse files
Slabko,Michael(mslabko)Slabko,Michael(mslabko)
Slabko,Michael(mslabko)
authored and
Slabko,Michael(mslabko)
committed
Merge pull request #21 from magento-goinc/goinc-bugsfixing
[GoInc] Bugs Fixing
2 parents 6d75339 + c40d408 commit 481bc3b

File tree

44 files changed

+302
-117
lines changed

Some content is hidden

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

44 files changed

+302
-117
lines changed

app/code/Magento/Backend/Block/Widget/Button/Item.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
namespace Magento\Backend\Block\Widget\Button;
88

99
/**
10-
* @method string getButtonKey
11-
* @method string getRegion
12-
* @method string getName
13-
* @method int getLevel
14-
* @method int getSortOrder
15-
* @method string getTitle
10+
* @method string getButtonKey()
11+
* @method string getRegion()
12+
* @method string getName()
13+
* @method int getLevel()
14+
* @method int getSortOrder()
15+
* @method string getTitle()
1616
*/
1717
class Item extends \Magento\Framework\DataObject
1818
{

app/code/Magento/Backend/Block/Widget/Button/Toolbar/Container.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
use Magento\Backend\Block\Widget\Button\ContextInterface;
1010

1111
/**
12-
* @method \Magento\Backend\Block\Widget\Button\Item getButtonItem
13-
* @method ContextInterface getContext
12+
* @method \Magento\Backend\Block\Widget\Button\Item getButtonItem()
13+
* @method ContextInterface getContext()
1414
* @method ContextInterface setContext(ContextInterface $context)
1515
*/
1616
class Container extends \Magento\Framework\View\Element\AbstractBlock

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

+9-1
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,18 @@ class Advanced extends Generic
3131
*/
3232
protected $_yesNo;
3333

34+
/**
35+
* @var array
36+
*/
37+
protected $disableScopeChangeList;
38+
3439
/**
3540
* @param \Magento\Backend\Block\Template\Context $context
3641
* @param \Magento\Framework\Registry $registry
3742
* @param \Magento\Framework\Data\FormFactory $formFactory
3843
* @param Yesno $yesNo
3944
* @param Data $eavData
45+
* @param array $disableScopeChangeList
4046
* @param array $data
4147
*/
4248
public function __construct(
@@ -45,10 +51,12 @@ public function __construct(
4551
\Magento\Framework\Data\FormFactory $formFactory,
4652
Yesno $yesNo,
4753
Data $eavData,
54+
array $disableScopeChangeList = ['sku'],
4855
array $data = []
4956
) {
5057
$this->_yesNo = $yesNo;
5158
$this->_eavData = $eavData;
59+
$this->disableScopeChangeList = $disableScopeChangeList;
5260
parent::__construct($context, $registry, $formFactory, $data);
5361
}
5462

@@ -229,7 +237,7 @@ protected function _prepareForm()
229237
);
230238

231239
$this->_eventManager->dispatch('product_attribute_form_build', ['form' => $form]);
232-
if ($attributeObject->getId() && !$attributeObject->getIsUserDefined()) {
240+
if (in_array($attributeObject->getAttributeCode(), $this->disableScopeChangeList)) {
233241
$form->getElement('is_global')->setDisabled(1);
234242
}
235243
$this->setForm($form);

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Product attribute add/edit form options tab
99
*
1010
* @method \Magento\Catalog\Block\Adminhtml\Product\Attribute\Edit\Tab\Options setReadOnly(bool $value)
11-
* @method null|bool getReadOnly
11+
* @method null|bool getReadOnly()
1212
*
1313
* @author Magento Core Team <core@magentocommerce.com>
1414
*/

app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Options/Option.php

+10
Original file line numberDiff line numberDiff line change
@@ -461,4 +461,14 @@ public function getCustomOptionsUrl()
461461
{
462462
return $this->getUrl('catalog/*/customOptions');
463463
}
464+
465+
/**
466+
* Return current product id
467+
*
468+
* @return null|int
469+
*/
470+
public function getCurrentProductId()
471+
{
472+
return $this->getProduct()->getId();
473+
}
464474
}

app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Options/Popup/Grid.php

+13-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,19 @@ public function _prepareMassaction()
6262
protected function _prepareCollection()
6363
{
6464
parent::_prepareCollection();
65-
$this->getCollection()->addFieldToFilter('has_options', 1);
65+
66+
if (null !== $this->getRequest()->getParam('current_product_id')) {
67+
$this->getCollection()->getSelect()->where(
68+
'e.entity_id != ?',
69+
$this->getRequest()->getParam('current_product_id')
70+
);
71+
}
72+
73+
$this->getCollection()->getSelect()->distinct()->join(
74+
['opt' => $this->getCollection()->getTable('catalog_product_option')],
75+
'opt.product_id = e.entity_id',
76+
null
77+
);
6678

6779
return $this;
6880
}

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -36,20 +36,20 @@ public function __construct(
3636
public function getAssignedProducts($categoryId)
3737
{
3838
$category = $this->categoryRepository->get($categoryId);
39-
$productsPosition = $category->getProductsPosition();
4039

41-
/** @var \Magento\Framework\Data\Collection\AbstractDb $products */
40+
/** @var \Magento\Catalog\Model\ResourceModel\Product\Collection $products */
4241
$products = $category->getProductCollection();
42+
$products->addFieldToSelect('position');
4343

4444
/** @var \Magento\Catalog\Api\Data\CategoryProductLinkInterface[] $links */
4545
$links = [];
4646

4747
/** @var \Magento\Catalog\Model\Product $product */
48-
foreach ($products->getItems() as $productId => $product) {
48+
foreach ($products->getItems() as $product) {
4949
/** @var \Magento\Catalog\Api\Data\CategoryProductLinkInterface $link */
5050
$link = $this->productLinkFactory->create();
5151
$link->setSku($product->getSku())
52-
->setPosition($productsPosition[$productId])
52+
->setPosition($product->getData('cat_index_position'))
5353
->setCategoryId($category->getId());
5454
$links[] = $link;
5555
}

app/code/Magento/Catalog/Model/Config/Source/Product/Options/Type.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function toOptionArray()
4343
$types[] = ['label' => __($type['label']), 'value' => $type['name']];
4444
}
4545
if (count($types)) {
46-
$groups[] = ['label' => __($option['label']), 'value' => $types];
46+
$groups[] = ['label' => __($option['label']), 'value' => $types, 'optgroup-name' => $option['label']];
4747
}
4848
}
4949

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
* @method array getAssociatedProductIds()
2626
* @method Product setNewVariationsAttributeSetId(int $value)
2727
* @method int getNewVariationsAttributeSetId()
28-
* @method int getPriceType
28+
* @method int getPriceType()
2929
* @method \Magento\Catalog\Model\ResourceModel\Product\Collection getCollection()
3030
* @method string getUrlKey()
3131
* @method Product setUrlKey(string $urlKey)

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public function beforeSave($object)
8585
// For duplicating we need copy original images.
8686
$duplicate = [];
8787
foreach ($value['images'] as &$image) {
88-
if (empty($image['value_id'])) {
88+
if (empty($image['value_id']) || !empty($image['removed'])) {
8989
continue;
9090
}
9191
$duplicate[$image['value_id']] = $this->copyImage($image['file']);

app/code/Magento/Catalog/Model/Product/Option/Type/File/ValidatorFile.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,21 @@ class ValidatorFile extends Validator
2121
*
2222
* @var string
2323
*/
24-
protected $path = '/custom_options';
24+
protected $path = 'custom_options';
2525

2626
/**
2727
* Relative path for quote folder
2828
*
2929
* @var string
3030
*/
31-
protected $quotePath = '/custom_options/quote';
31+
protected $quotePath = 'custom_options/quote';
3232

3333
/**
3434
* Relative path for order folder
3535
*
3636
* @var string
3737
*/
38-
protected $orderPath = '/custom_options/order';
38+
protected $orderPath = 'custom_options/order';
3939

4040
/**
4141
* @var \Magento\Framework\Filesystem\Directory\WriteInterface
@@ -175,12 +175,12 @@ public function validate($processingParams, $option)
175175
$_height = $imageSize[1];
176176
}
177177
}
178-
$uri = $this->filesystem->getUri(DirectoryList::MEDIA);
178+
179179
$userValue = [
180180
'type' => $fileInfo['type'],
181181
'title' => $fileInfo['name'],
182-
'quote_path' => $uri . $this->quotePath . $filePath,
183-
'order_path' => $uri . $this->orderPath . $filePath,
182+
'quote_path' => $this->quotePath . $filePath,
183+
'order_path' => $this->orderPath . $filePath,
184184
'fullpath' => $fileFullPath,
185185
'size' => $fileInfo['size'],
186186
'width' => $_width,

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

+19
Original file line numberDiff line numberDiff line change
@@ -671,4 +671,23 @@ public function getAnchorsAbove(array $filterIds, $storeId = 0)
671671

672672
return $this->getConnection()->fetchCol($select);
673673
}
674+
675+
/**
676+
* Get positions of associated to category products
677+
*
678+
* @param \Magento\Catalog\Model\Category $category
679+
* @return array
680+
*/
681+
public function getProductsPosition($category)
682+
{
683+
$select = $this->getConnection()->select()->from(
684+
$this->getTable('catalog_category_product'),
685+
['product_id', 'position']
686+
)->where(
687+
'category_id = :category_id'
688+
);
689+
$bind = ['category_id' => (int)$category->getId()];
690+
691+
return $this->getConnection()->fetchPairs($select, $bind);
692+
}
674693
}

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

+4-1
Original file line numberDiff line numberDiff line change
@@ -324,11 +324,12 @@ public function duplicate($attributeId, $newFiles, $originalProductId, $newProdu
324324
foreach ($this->getConnection()->fetchAll($select) as $row) {
325325
$data = [
326326
'attribute_id' => $attributeId,
327-
'entity_id' => $newProductId,
328327
'value' => isset($newFiles[$row['value_id']]) ? $newFiles[$row['value_id']] : $row['value'],
329328
];
330329

331330
$valueIdMap[$row['value_id']] = $this->insertGallery($data);
331+
$this->bindValueToEntity($valueIdMap[$row['value_id']], $newProductId);
332+
332333
}
333334

334335
if (count($valueIdMap) == 0) {
@@ -344,6 +345,8 @@ public function duplicate($attributeId, $newFiles, $originalProductId, $newProdu
344345
);
345346

346347
foreach ($this->getConnection()->fetchAll($select) as $row) {
348+
unset($row['record_id']);
349+
$row['entity_id'] = $newProductId;
347350
$row['value_id'] = $valueIdMap[$row['value_id']];
348351
$this->insertGalleryValueInStore($row);
349352
}

app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Attribute/Edit/Tab/AdvancedTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public function testToHtml()
8989
$this->localeDate->expects($this->any())->method('getDateFormat')->willReturn('mm/dd/yy');
9090
$entityType->expects($this->any())->method('getEntityTypeCode')->willReturn('entity_type_code');
9191
$this->eavData->expects($this->any())->method('getFrontendClasses')->willReturn([]);
92-
$formElement->expects($this->exactly(3))->method('setDisabled')->willReturnSelf();
92+
$formElement->expects($this->exactly(2))->method('setDisabled')->willReturnSelf();
9393
$this->yesNo->expects($this->any())->method('toOptionArray')->willReturn(['yes', 'no']);
9494
$this->filesystem->expects($this->any())->method('getDirectoryRead')->willReturn($directoryReadInterface);
9595
$directoryReadInterface->expects($this->any())->method('getRelativePath')->willReturn('relative_path');

app/code/Magento/Catalog/Test/Unit/Model/CategoryLinkManagementTest.php

+5-4
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function testGetAssignedProducts()
4444
{
4545
$categoryId = 42;
4646
$productId = 55;
47-
$productsPosition = [$productId => 25];
47+
$position = 25;
4848
$productSku = 'testSku';
4949
$categoryProductLinkMock = $this->getMock('\Magento\Catalog\Api\Data\CategoryProductLinkInterface');
5050
$categoryMock = $this->getMock(
@@ -56,13 +56,14 @@ public function testGetAssignedProducts()
5656
);
5757
$productMock = $this->getMock('\Magento\Catalog\Model\Product', [], [], '', false);
5858
$productMock->expects($this->once())->method('getSku')->willReturn($productSku);
59+
$productMock->expects($this->once())->method('getData')->with('cat_index_position')->willReturn($position);
5960
$items = [$productId => $productMock];
60-
$productsMock = $this->getMock('\Magento\Framework\Data\Collection\AbstractDb', [], [], '', false);
61+
$productsMock = $this->getMock('Magento\Catalog\Model\ResourceModel\Product\Collection', [], [], '', false);
6162
$this->categoryRepositoryMock->expects($this->once())->method('get')->with($categoryId)
6263
->willReturn($categoryMock);
63-
$categoryMock->expects($this->once())->method('getProductsPosition')->willReturn($productsPosition);
6464
$categoryMock->expects($this->once())->method('getProductCollection')->willReturn($productsMock);
6565
$categoryMock->expects($this->once())->method('getId')->willReturn($categoryId);
66+
$productsMock->expects($this->once())->method('addFieldToSelect')->with('position')->willReturnSelf();
6667
$productsMock->expects($this->once())->method('getItems')->willReturn($items);
6768
$this->productLinkFactoryMock->expects($this->once())->method('create')->willReturn($categoryProductLinkMock);
6869
$categoryProductLinkMock->expects($this->once())
@@ -71,7 +72,7 @@ public function testGetAssignedProducts()
7172
->willReturnSelf();
7273
$categoryProductLinkMock->expects($this->once())
7374
->method('setPosition')
74-
->with(25)
75+
->with($position)
7576
->willReturnSelf();
7677
$categoryProductLinkMock->expects($this->once())
7778
->method('setCategoryId')

app/code/Magento/Catalog/Test/Unit/Model/Config/Source/Product/Options/TypeTest.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,11 @@ public function testToOptionArray()
5151
];
5252
$expect = [
5353
['value' => '', 'label' => __('-- Please select --')],
54-
['label' => 'optionLabel', 'value' => [['label' => 'typeLabel', 'value' => 'typeName']]],
54+
[
55+
'label' => 'optionLabel',
56+
'optgroup-name' => 'optionLabel',
57+
'value' => [['label' => 'typeLabel', 'value' => 'typeName']]
58+
],
5559
];
5660

5761
$this->productOptionConfig->expects($this->any())->method('getAll')->will($this->returnValue($allOptions));

app/code/Magento/Catalog/Ui/Component/Listing/Columns/Price.php

+2-4
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,12 @@ public function prepareDataSource(array $dataSource)
5353
$store = $this->storeManager->getStore(
5454
$this->context->getFilterParam('store_id', \Magento\Store\Model\Store::DEFAULT_STORE_ID)
5555
);
56-
$currencyCode = $store->getCurrentCurrencyCode();
57-
$currencyRate = $store->getCurrentCurrencyRate();
58-
$currency = $this->localeCurrency->getCurrency($currencyCode);
56+
$currency = $this->localeCurrency->getCurrency($store->getBaseCurrencyCode());
5957

6058
$fieldName = $this->getData('name');
6159
foreach ($dataSource['data']['items'] as & $item) {
6260
if (isset($item[$fieldName])) {
63-
$item[$fieldName] = $currency->toCurrency(sprintf("%f", $item[$fieldName] * $currencyRate));
61+
$item[$fieldName] = $currency->toCurrency(sprintf("%f", $item[$fieldName]));
6462
}
6563
}
6664
}

app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/edit.phtml

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
</button>
2222
<ul class="dropdown-menu">
2323
<li><input type="text" id="product-template-suggest" class="search"
24-
placeholder="start typing to search template"/></li>
24+
placeholder="<?php /* @noEscape */ echo __('start typing to search template'); ?>"/></li>
2525
</ul>
2626
</div>
2727
</div>

app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/edit/options.phtml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
?>
1010
<?php /** @var $block \Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Options */ ?>
1111

12-
<div class="fieldset-wrapper" id="product-custom-options-wrapper">
12+
<div class="fieldset-wrapper" id="product-custom-options-wrapper" data-block="product-custom-options">
1313
<div class="fieldset-wrapper-title">
1414
<strong class="title">
1515
<span><?php /* @escapeNotVerified */ echo __('Custom Options') ?></span>

app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/edit/options/option.phtml

+2-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ require([
8888
], function(jQuery){
8989

9090
jQuery(function ($) {
91-
var fieldSet = $('#Custom_Options');
91+
var fieldSet = $('[data-block=product-custom-options]');
9292
fieldSet.customOptions(<?php /* @escapeNotVerified */ echo $this->helper('Magento\Framework\Json\Helper\Data')->jsonEncode(
9393
[
9494
'fieldId' => $block->getFieldId(),
@@ -97,6 +97,7 @@ jQuery(function ($) {
9797
'customOptionsUrl' => $block->getCustomOptionsUrl(),
9898
'isReadonly' => $block->isReadonly(),
9999
'itemCount' => $block->getItemCount(),
100+
'currentProductId' => $block->getCurrentProductId(),
100101
]
101102
)?>);
102103
//adding data to templates

app/code/Magento/Catalog/view/adminhtml/templates/product/edit/attribute/search.phtml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<input data-role="product-attribute-search"
1818
data-group="<?php echo $block->escapeHtml($block->getGroupCode()); ?>"
1919
class="search" type="text"
20-
placeholder="start typing to search attribute"/>
20+
placeholder="<?php /* @noEscape */ echo __('start typing to search attribute'); ?>" />
2121
</div>
2222
</div>
2323

app/code/Magento/Catalog/view/adminhtml/web/js/custom-options.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ define([
179179
});
180180
importContainer.load(
181181
this.options.productGridUrl,
182-
{form_key: this.options.formKey},
182+
{form_key: this.options.formKey, current_product_id : this.options.currentProductId},
183183
function () {
184184
importContainer.modal('openModal');
185185
}
@@ -194,7 +194,8 @@ define([
194194
var widget = this,
195195
currentElement = $(event.target),
196196
parentId = '#' + currentElement.closest('.fieldset-alt').attr('id'),
197-
group = currentElement.find('[value="' + currentElement.val() + '"]').closest('optgroup').attr('label'),
197+
group = currentElement.find('[value="' + currentElement.val() + '"]')
198+
.closest('optgroup').attr('data-optgroup-name'),
198199
previousGroup = $(parentId + '_previous_group').val(),
199200
previousBlock = $(parentId + '_type_' + previousGroup),
200201
tmpl;

0 commit comments

Comments
 (0)