Skip to content

Commit aa2088f

Browse files
committed
Merge pull request #438 from magento-goinc/MAGETWO-23739
[GoInc] New Product Data Grid and Configurable Product Variations + Bugs
2 parents 3d029aa + de45154 commit aa2088f

File tree

244 files changed

+8661
-4895
lines changed

Some content is hidden

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

244 files changed

+8661
-4895
lines changed
Loading

app/code/Magento/Catalog/Api/Data/EavAttributeInterface.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ interface EavAttributeInterface extends \Magento\Eav\Api\Data\AttributeInterface
2121

2222
const IS_FILTERABLE_IN_SEARCH = 'is_filterable_in_search';
2323

24+
const IS_USED_IN_GRID = 'is_used_in_grid';
25+
26+
const IS_VISIBLE_IN_GRID = 'is_visible_in_grid';
27+
28+
const IS_FILTERABLE_IN_GRID = 'is_filterable_in_grid';
29+
2430
const POSITION = 'position';
2531

2632
const APPLY_TO = 'apply_to';
@@ -112,6 +118,27 @@ public function setIsFilterable($isFilterable);
112118
*/
113119
public function getIsFilterableInSearch();
114120

121+
/**
122+
* Whether it is used in catalog product grid
123+
*
124+
* @return bool|null
125+
*/
126+
public function getIsUsedInGrid();
127+
128+
/**
129+
* Whether it is visible in catalog product grid
130+
*
131+
* @return bool|null
132+
*/
133+
public function getIsVisibleInGrid();
134+
135+
/**
136+
* Whether it is filterable in catalog product grid
137+
*
138+
* @return bool|null
139+
*/
140+
public function getIsFilterableInGrid();
141+
115142
/**
116143
* Set whether it is used in search results layered navigation
117144
*

app/code/Magento/Catalog/Block/Adminhtml/Product.php

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,6 @@
1313

1414
class Product extends \Magento\Backend\Block\Widget\Container
1515
{
16-
/**
17-
* @var string
18-
*/
19-
protected $_template = 'catalog/product.phtml';
20-
2116
/**
2217
* @var \Magento\Catalog\Model\Product\TypeFactory
2318
*/
@@ -63,10 +58,6 @@ protected function _prepareLayout()
6358
];
6459
$this->buttonList->add('add_new', $addButtonProps);
6560

66-
$this->setChild(
67-
'grid',
68-
$this->getLayout()->createBlock('Magento\Catalog\Block\Adminhtml\Product\Grid', 'product.grid')
69-
);
7061
return parent::_prepareLayout();
7162
}
7263

@@ -111,16 +102,6 @@ protected function _getProductCreateUrl($type)
111102
);
112103
}
113104

114-
/**
115-
* Render grid
116-
*
117-
* @return string
118-
*/
119-
public function getGridHtml()
120-
{
121-
return $this->getChildHtml('grid');
122-
}
123-
124105
/**
125106
* Check whether it is single store mode
126107
*

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

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function __construct(
5656
* Adding product form elements for editing attribute
5757
*
5858
* @return $this
59-
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
59+
* @SuppressWarnings(PHPMD)
6060
*/
6161
protected function _prepareForm()
6262
{
@@ -162,6 +162,41 @@ protected function _prepareForm()
162162
]
163163
);
164164

165+
$fieldset->addField(
166+
'is_used_in_grid',
167+
'select',
168+
[
169+
'name' => 'is_used_in_grid',
170+
'label' => __('Add to Column Options'),
171+
'title' => __('Add to Column Options'),
172+
'values' => $yesno,
173+
'value' => $attributeObject->getData('is_used_in_grid') ?: 1,
174+
'note' => __('Select "Yes" to add this attribute to the list of column options in the product grid.'),
175+
]
176+
);
177+
178+
$fieldset->addField(
179+
'is_visible_in_grid',
180+
'hidden',
181+
[
182+
'name' => 'is_visible_in_grid',
183+
'value' => $attributeObject->getData('is_visible_in_grid') ?: 1,
184+
]
185+
);
186+
187+
$fieldset->addField(
188+
'is_filterable_in_grid',
189+
'select',
190+
[
191+
'name' => 'is_filterable_in_grid',
192+
'label' => __('Use in Filter Options'),
193+
'title' => __('Use in Filter Options'),
194+
'values' => $yesno,
195+
'value' => $attributeObject->getData('is_filterable_in_grid') ?: 1,
196+
'note' => __('Select "Yes" to add this attribute to the list of filter options in the product grid.'),
197+
]
198+
);
199+
165200
if ($attributeObject->getId()) {
166201
$form->getElement('attribute_code')->setDisabled(1);
167202
if (!$attributeObject->getIsUserDefined()) {

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ public function getOptionValues()
299299
$value['id'] = $option->getOptionId();
300300
$value['item_count'] = $this->getItemCount();
301301
$value['option_id'] = $option->getOptionId();
302-
$value['title'] = $this->escapeHtml($option->getTitle());
302+
$value['title'] = $option->getTitle();
303303
$value['type'] = $option->getType();
304304
$value['is_require'] = $option->getIsRequire();
305305
$value['sort_order'] = $option->getSortOrder();
@@ -323,13 +323,13 @@ public function getOptionValues()
323323
'item_count' => max($itemCount, $_value->getOptionTypeId()),
324324
'option_id' => $_value->getOptionId(),
325325
'option_type_id' => $_value->getOptionTypeId(),
326-
'title' => $this->escapeHtml($_value->getTitle()),
326+
'title' => $_value->getTitle(),
327327
'price' => $showPrice ? $this->getPriceValue(
328328
$_value->getPrice(),
329329
$_value->getPriceType()
330330
) : '',
331331
'price_type' => $showPrice ? $_value->getPriceType() : 0,
332-
'sku' => $this->escapeHtml($_value->getSku()),
332+
'sku' => $_value->getSku(),
333333
'sort_order' => $_value->getSortOrder(),
334334
];
335335

@@ -364,7 +364,7 @@ public function getOptionValues()
364364
$option->getPriceType()
365365
) : '';
366366
$value['price_type'] = $option->getPriceType();
367-
$value['sku'] = $this->escapeHtml($option->getSku());
367+
$value['sku'] = $option->getSku();
368368
$value['max_characters'] = $option->getMaxCharacters();
369369
$value['file_extension'] = $option->getFileExtension();
370370
$value['image_size_x'] = $option->getImageSizeX();

app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/BaseImage.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,10 @@ public function getElementHtml()
100100
<img class="spacer" src="{$spacerImage}"/>
101101
<p class="image-placeholder-text">{$imagePlaceholderText}</p>
102102
</div>
103-
<script id="{$htmlId}-template" class="image-template" type="text/x-magento-template">
103+
<script id="{$htmlId}-template" data-template="image" type="text/x-magento-template">
104104
<div class="image">
105105
<img class="spacer" src="{$spacerImage}"/>
106-
<img
106+
<img
107107
class="product-image"
108108
src="<%- data.url %>"
109109
data-position="<%- data.position %>"

app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Edit.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ public function execute()
3535
if (!$this->_validateProducts()) {
3636
return $this->resultRedirectFactory->create()->setPath('catalog/product/', ['_current' => true]);
3737
}
38-
return $this->resultPageFactory->create();
38+
$resultPage = $this->resultPageFactory->create();
39+
$resultPage->getConfig()->getTitle()->prepend(__('Update Attributes'));
40+
return $resultPage;
3941
}
4042
}

app/code/Magento/Catalog/Controller/Adminhtml/Product/MassDelete.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class MassDelete extends \Magento\Catalog\Controller\Adminhtml\Product
1313
*/
1414
public function execute()
1515
{
16-
$productIds = $this->getRequest()->getParam('product');
16+
$productIds = $this->getRequest()->getParam('selected');
1717
if (!is_array($productIds) || empty($productIds)) {
1818
$this->messageManager->addError(__('Please select product(s).'));
1919
} else {

app/code/Magento/Catalog/Controller/Adminhtml/Product/Save.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ public function __construct(
5151
*
5252
* @return \Magento\Backend\Model\View\Result\Redirect
5353
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
54+
* @SuppressWarnings(PHPMD.NPathComplexity)
5455
*/
5556
public function execute()
5657
{
@@ -122,7 +123,7 @@ public function execute()
122123
return $resultRedirect;
123124
}
124125

125-
if ($redirectBack === 'new') {
126+
if ($redirectBack === 'new' && isset($product)) {
126127
$resultRedirect->setPath(
127128
'catalog/*/new',
128129
['set' => $product->getAttributeSetId(), 'type' => $product->getTypeId()]

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

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ protected function _reset()
144144
* @param string|null $imageFile
145145
* @return $this
146146
*/
147-
public function init(\Magento\Catalog\Model\Product $product, $attributeName, $imageFile = null)
147+
public function init($product, $attributeName, $imageFile = null)
148148
{
149149
$this->_reset();
150150
$this->_setModel($this->_productImageFactory->create());
@@ -349,14 +349,14 @@ public function placeholder($fileName)
349349

350350
/**
351351
* Get Placeholder
352-
*
352+
* @param null|string $placeholder
353353
* @return string
354354
*/
355-
public function getPlaceholder()
355+
public function getPlaceholder($placeholder = null)
356356
{
357357
if (!$this->_placeholder) {
358-
$attr = $this->_getModel()->getDestinationSubdir();
359-
$this->_placeholder = 'Magento_Catalog::images/product/placeholder/' . $attr . '.jpg';
358+
$placeholder = $placeholder?: $this->_getModel()->getDestinationSubdir();
359+
$this->_placeholder = 'Magento_Catalog::images/product/placeholder/' . $placeholder . '.jpg';
360360
}
361361
return $this->_placeholder;
362362
}
@@ -439,12 +439,13 @@ public function getResizedImageInfo()
439439
}
440440

441441
/**
442+
* @param null|string $placeholder
442443
* @return string
443444
*/
444-
protected function getDefaultPlaceholderUrl()
445+
public function getDefaultPlaceholderUrl($placeholder = null)
445446
{
446447
try {
447-
$url = $this->_assetRepo->getUrl($this->getPlaceholder());
448+
$url = $this->_assetRepo->getUrl($this->getPlaceholder($placeholder));
448449
} catch (\Exception $e) {
449450
$this->_logger->critical($e);
450451
$url = $this->_urlBuilder->getUrl('', ['_direct' => 'core/index/notFound']);

0 commit comments

Comments
 (0)