Skip to content

Commit f8533bc

Browse files
author
Miniailo, Igor(iminiailo)
committed
Merge pull request #154 from magento-dragons/develop
[DRAGONS] S63
2 parents 44e90c4 + 57dffd9 commit f8533bc

File tree

21 files changed

+310
-55
lines changed

21 files changed

+310
-55
lines changed

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

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -89,18 +89,4 @@ public function getButtonHtml($label, $onclick, $class = '', $buttonId = null, $
8989
$dataAttr
9090
)->toHtml();
9191
}
92-
93-
/**
94-
* @return string
95-
*/
96-
public function getGlobalIcon()
97-
{
98-
return '<img src="' . $this->getViewFileUrl(
99-
'images/fam_link.gif'
100-
) . '" alt="' . __(
101-
'Global Attribute'
102-
) . '" title="' . __(
103-
'This attribute shares the same value in all stores.'
104-
) . '" class="attribute-global"/>';
105-
}
10692
}

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,29 @@ class Front extends Generic
2323
*/
2424
protected $_yesNo;
2525

26+
/**
27+
* @var array
28+
*/
29+
private $disableSearchable;
30+
2631
/**
2732
* @param \Magento\Backend\Block\Template\Context $context
2833
* @param \Magento\Framework\Registry $registry
2934
* @param \Magento\Framework\Data\FormFactory $formFactory
3035
* @param Yesno $yesNo
3136
* @param array $data
37+
* @param array $disableSearchable
3238
*/
3339
public function __construct(
3440
\Magento\Backend\Block\Template\Context $context,
3541
\Magento\Framework\Registry $registry,
3642
\Magento\Framework\Data\FormFactory $formFactory,
3743
Yesno $yesNo,
38-
array $data = []
44+
array $data = [],
45+
array $disableSearchable = []
3946
) {
4047
$this->_yesNo = $yesNo;
48+
$this->disableSearchable = $disableSearchable;
4149
parent::__construct($context, $registry, $formFactory, $data);
4250
}
4351

@@ -63,6 +71,7 @@ protected function _prepareForm()
6371
['legend' => __('Frontend Properties'), 'collapsable' => $this->getRequest()->has('popup')]
6472
);
6573

74+
$attrCode = $attributeObject->getAttributeCode();
6675
$fieldset->addField(
6776
'is_searchable',
6877
'select',
@@ -71,6 +80,7 @@ protected function _prepareForm()
7180
'label' => __('Use in Search'),
7281
'title' => __('Use in Search'),
7382
'values' => $yesnoSource,
83+
'disabled' => isset($this->disableSearchable[$attrCode]) && $this->disableSearchable[$attrCode] ? 1 : 0
7484
]
7585
);
7686

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,18 @@ public function shouldRenderQuantity()
350350
return !$this->productTypeConfig->isProductSet($this->getProduct()->getTypeId());
351351
}
352352

353+
/**
354+
* Get Validation Rules for Quantity field
355+
*
356+
* @return array
357+
*/
358+
public function getQuantityValidators()
359+
{
360+
$validators = [];
361+
$validators['required-number'] = true;
362+
return $validators;
363+
}
364+
353365
/**
354366
* Return identifiers for produced content
355367
*

app/code/Magento/Catalog/etc/adminhtml/di.xml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,18 @@
6666
<type name="Magento\Catalog\Model\Resource\Attribute">
6767
<plugin name="invalidate_pagecache_after_attribute_save" type="Magento\Catalog\Plugin\Model\Resource\Attribute\Save" />
6868
</type>
69+
<type name="Magento\Catalog\Block\Adminhtml\Product\Attribute\Edit\Tab\Front">
70+
<arguments>
71+
<argument name="disableSearchable" xsi:type="array">
72+
<item name="visibility" xsi:type="boolean">true</item>
73+
<item name="url_key" xsi:type="boolean">true</item>
74+
<item name="status" xsi:type="boolean">true</item>
75+
<item name="group_price" xsi:type="boolean">true</item>
76+
<item name="price_type" xsi:type="boolean">true</item>
77+
<item name="category_ids" xsi:type="boolean">true</item>
78+
<item name="media_gallery" xsi:type="boolean">true</item>
79+
<item name="country_of_manufacture" xsi:type="boolean">true</item>
80+
</argument>
81+
</arguments>
82+
</type>
6983
</config>

app/code/Magento/Catalog/view/frontend/templates/product/view/addtocart.phtml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,8 @@
2323
maxlength="12"
2424
value="<?php echo $block->getProductDefaultQty() * 1 ?>"
2525
title="<?php echo __('Qty') ?>" class="input-text qty"
26-
<?php if ($_product->getStockItem() && $_product->getStockItem()->getIsQtyDecimal()) : ?>
27-
data-validate="{'required-number':true, 'validate-greater-than-zero':true}"
28-
<?php else: ?>
29-
data-validate="{'required-number':true, digits:true}"
30-
<?php endif; ?> />
26+
data-validate="<?php echo $block->escapeHtml(json_encode($block->getQuantityValidators())) ?>"
27+
/>
3128
</div>
3229
</div>
3330
<?php endif; ?>
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\CatalogInventory\Block\Plugin;
7+
8+
use Magento\CatalogInventory\Api\StockRegistryInterface;
9+
10+
class ProductView
11+
{
12+
/**
13+
* @var StockRegistryInterface
14+
*/
15+
private $stockRegistry;
16+
17+
/**
18+
* @param StockRegistryInterface $stockRegistry
19+
*/
20+
public function __construct(
21+
StockRegistryInterface $stockRegistry
22+
) {
23+
$this->stockRegistry = $stockRegistry;
24+
}
25+
26+
/**
27+
* @param \Magento\Catalog\Block\Product\View $block
28+
* @param array $validators
29+
* @return array
30+
*/
31+
public function afterGetQuantityValidators(
32+
\Magento\Catalog\Block\Product\View $block,
33+
array $validators
34+
) {
35+
$stockItem = $this->stockRegistry->getStockItem(
36+
$block->getProduct()->getId(),
37+
$block->getProduct()->getStore()->getWebsiteId()
38+
);
39+
40+
$params = [];
41+
$params['minAllowed'] = max((float)$stockItem->getQtyMinAllowed(), 1);
42+
if ($stockItem->getQtyMaxAllowed()) {
43+
$params['maxAllowed'] = $stockItem->getQtyMaxAllowed();
44+
}
45+
if ($stockItem->getQtyIncrements() > 0) {
46+
$params['qtyIncrements'] = (float)$stockItem->getQtyIncrements();
47+
}
48+
$validators['validate-item-quantity'] = $params;
49+
50+
return $validators;
51+
}
52+
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,7 @@
4949
<type name="Magento\Store\Model\Resource\Group">
5050
<plugin name="storeGroupResourceAroundBeforeSave" type="\Magento\CatalogInventory\Model\Indexer\Stock\Plugin\StoreGroup"/>
5151
</type>
52+
<type name="Magento\Catalog\Block\Product\View">
53+
<plugin name="quantityValidators" type="Magento\CatalogInventory\Block\Plugin\ProductView" />
54+
</type>
5255
</config>
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\CatalogSearch\Block\Plugin;
7+
8+
use Magento\Catalog\Block\Adminhtml\Product\Attribute\Edit\Tab\Front;
9+
use Magento\CatalogSearch\Model\Source\Weight;
10+
use Magento\Framework\Data\Form;
11+
use Magento\Framework\Data\Form\Element\Fieldset;
12+
13+
class FrontTabPlugin
14+
{
15+
/**
16+
* @var Weight
17+
*/
18+
private $weightSource;
19+
20+
/**
21+
* @param Weight $weightSource
22+
*/
23+
public function __construct(Weight $weightSource)
24+
{
25+
$this->weightSource = $weightSource;
26+
}
27+
28+
/**
29+
* @param Front $subject
30+
* @param callable $proceed
31+
* @param Form $form
32+
* @return Front
33+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
34+
*/
35+
public function aroundSetForm(Front $subject, \Closure $proceed, Form $form)
36+
{
37+
$block = $proceed($form);
38+
/** @var Fieldset $fieldset */
39+
$fieldset = $form->getElement('front_fieldset');
40+
$fieldset->addField(
41+
'search_weight',
42+
'select',
43+
[
44+
'name' => 'search_weight',
45+
'label' => __('Search Weight'),
46+
'values' => $this->weightSource->getOptions()
47+
],
48+
'is_searchable'
49+
);
50+
51+
$subject->getChildBlock('form_after')
52+
->addFieldMap(
53+
'search_weight',
54+
'search_weight'
55+
)
56+
->addFieldDependence(
57+
'search_weight',
58+
'searchable',
59+
'1'
60+
);
61+
return $block;
62+
}
63+
}

app/code/Magento/CatalogSearch/Model/Resource/Engine.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -224,16 +224,6 @@ public function prepareEntityIndex($index, $separator = ' ')
224224
return $this->_catalogSearchData->prepareIndexdata($index, $separator);
225225
}
226226

227-
/**
228-
* Define if Layered Navigation is allowed
229-
*
230-
* @return bool
231-
*/
232-
public function isLayeredNavigationAllowed()
233-
{
234-
return true;
235-
}
236-
237227
/**
238228
* Define if engine is available
239229
*

app/code/Magento/CatalogSearch/Model/Resource/EngineInterface.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,6 @@ public function cleanIndex($storeId = null, $entityId = null, $entity = 'product
7474
*/
7575
public function prepareEntityIndex($index, $separator = ' ');
7676

77-
/**
78-
* Define if Layered Navigation is allowed
79-
*
80-
* @return bool
81-
*/
82-
public function isLayeredNavigationAllowed();
83-
8477
/**
8578
* Define if engine is available
8679
*
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\CatalogSearch\Model\Source;
7+
8+
/**
9+
* Attribute weight options
10+
*/
11+
class Weight
12+
{
13+
/**
14+
* Quick search weights
15+
*
16+
* @var int[]
17+
*/
18+
protected $_weights = [1, 2, 3, 4, 5];
19+
20+
/**
21+
* Retrieve search weights as options array
22+
*
23+
* @return array
24+
*/
25+
public function getOptions()
26+
{
27+
$res = [];
28+
foreach ($this->getValues() as $value) {
29+
$res[] = ['value' => $value, 'label' => $value];
30+
}
31+
return $res;
32+
}
33+
34+
/**
35+
* Retrieve search weights array
36+
*
37+
* @return int[]
38+
*/
39+
public function getValues()
40+
{
41+
return $this->_weights;
42+
}
43+
}

app/code/Magento/CatalogSearch/Setup/InstallSchema.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,18 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
8383

8484
$installer->getConnection()->createTable($table);
8585

86+
$installer->getConnection()->addColumn(
87+
$installer->getTable('catalog_eav_attribute'),
88+
'search_weight',
89+
[
90+
'type' => \Magento\Framework\DB\Ddl\Table::TYPE_FLOAT,
91+
'unsigned' => true,
92+
'nullable' => false,
93+
'default' => '3',
94+
'comment' => 'Search Weight'
95+
]
96+
);
97+
8698
$installer->endSetup();
8799

88100
}

app/code/Magento/CatalogSearch/etc/adminhtml/di.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,7 @@
1616
<argument name="storage" xsi:type="object">Magento\CatalogSearch\Model\Session\Storage</argument>
1717
</arguments>
1818
</virtualType>
19+
<type name="\Magento\Catalog\Block\Adminhtml\Product\Attribute\Edit\Tab\Front">
20+
<plugin name="search_weigh" type="\Magento\CatalogSearch\Block\Plugin\FrontTabPlugin" />
21+
</type>
1922
</config>

app/code/Magento/CatalogSearch/etc/search_request.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
</query>
2121
<query xsi:type="matchQuery" value="$search_term$" name="search">
2222
<match field="sku" boost="1"/>
23+
<match field="*" boost="1"/>
2324
</query>
2425
<query xsi:type="filteredQuery" name="category">
2526
<filterReference clause="must" ref="category_filter"/>

app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/config.phtml

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,12 @@ require([
6868
isLocked = function (element) {
6969
return element.is('[data-locked]');
7070
},
71-
disableElement = function (element) {
71+
setElementDisabled = function (element, state, triggerEvent) {
7272
if (!isLocked(element)) {
73-
element.prop('disabled', true).trigger('change');
74-
}
75-
},
76-
enableElement = function (element) {
77-
if (!isLocked(element)) {
78-
element.removeProp('disabled').trigger('change');
73+
element.prop('disabled', state);
74+
if (triggerEvent) {
75+
element.trigger('change')
76+
}
7977
}
8078
};
8179

@@ -89,8 +87,8 @@ require([
8987

9088
inventoryQty.prop('disabled', true);
9189
inventoryAvailabilityField.removeProp('disabled');
92-
disableElement(qtyField);
93-
enableElement(stockAvailabilityField);
90+
setElementDisabled(qtyField, true, true);
91+
setElementDisabled(stockAvailabilityField, false, false);
9492
$.each($.mage.variationsAttributes($('#configurable-attributes-container')).getAttributes(), function() {
9593
$('#attribute-' + this.code + '-container select').prop('disabled', true);
9694
})
@@ -104,8 +102,8 @@ require([
104102
.removeProp('disabled');
105103
inventoryQty.removeProp('disabled');
106104
inventoryAvailabilityField.prop('disabled', true);
107-
disableElement(stockAvailabilityField);
108-
enableElement(qtyField);
105+
setElementDisabled(stockAvailabilityField, true, false);
106+
setElementDisabled(qtyField, false, true);
109107
})
110108
.collapse(hasVariations ? 'show' : 'hide');
111109

0 commit comments

Comments
 (0)