Skip to content

Commit

Permalink
Merge pull request #934 from magento-engcom/develop-prs-isolated
Browse files Browse the repository at this point in the history
[EngCom] Public Pull Requests
  • Loading branch information
vrann authored Mar 16, 2017
2 parents 16bbf9d + d906d6c commit f7a552f
Show file tree
Hide file tree
Showing 10 changed files with 71 additions and 32 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
83 changes: 60 additions & 23 deletions app/code/Magento/CatalogSearch/Model/Layer/Filter/Attribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function __construct(
public function apply(\Magento\Framework\App\RequestInterface $request)
{
$attributeValue = $request->getParam($this->_requestVar);
if (empty($attributeValue)) {
if (empty($attributeValue) && !is_numeric($attributeValue)) {
return $this;
}
$attribute = $this->getAttributeModel();
Expand Down Expand Up @@ -84,9 +84,10 @@ protected function _getItemsData()
->getProductCollection();
$optionsFacetedData = $productCollection->getFacetedData($attribute->getAttributeCode());

if (count($optionsFacetedData) === 0
&& $this->getAttributeIsFilterable($attribute) !== static::ATTRIBUTE_OPTIONS_ONLY_WITH_RESULTS
) {
$isAttributeFilterable =
$this->getAttributeIsFilterable($attribute) === static::ATTRIBUTE_OPTIONS_ONLY_WITH_RESULTS;

if (count($optionsFacetedData) === 0 && !$isAttributeFilterable) {
return $this->itemDataBuilder->build();
}

Expand All @@ -95,28 +96,64 @@ protected function _getItemsData()
$options = $attribute->getFrontend()
->getSelectOptions();
foreach ($options as $option) {
if (empty($option['value'])) {
continue;
}
$this->buildOptionData($option, $isAttributeFilterable, $optionsFacetedData, $productSize);
}

$value = $option['value'];
return $this->itemDataBuilder->build();
}

$count = isset($optionsFacetedData[$value]['count'])
? (int)$optionsFacetedData[$value]['count']
: 0;
// Check filter type
if ($this->getAttributeIsFilterable($attribute) === static::ATTRIBUTE_OPTIONS_ONLY_WITH_RESULTS
&& (!$this->isOptionReducesResults($count, $productSize) || $count === 0)
) {
continue;
}
$this->itemDataBuilder->addItemData(
$this->tagFilter->filter($option['label']),
$value,
$count
);
/**
* Build option data
*
* @param array $option
* @param boolean $isAttributeFilterable
* @param array $optionsFacetedData
* @param int $productSize
* @return void
*/
private function buildOptionData($option, $isAttributeFilterable, $optionsFacetedData, $productSize)
{
$value = $this->getOptionValue($option);
if ($value === false) {
return;
}
$count = $this->getOptionCount($value, $optionsFacetedData);
if ($isAttributeFilterable && (!$this->isOptionReducesResults($count, $productSize) || $count === 0)) {
return;
}

return $this->itemDataBuilder->build();
$this->itemDataBuilder->addItemData(
$this->tagFilter->filter($option['label']),
$value,
$count
);
}

/**
* Retrieve option value if it exists
*
* @param array $option
* @return bool|string
*/
private function getOptionValue($option)
{
if (empty($option['value']) && !is_numeric($option['value'])) {
return false;
}
return $option['value'];
}

/**
* Retrieve count of the options
*
* @param int|string $value
* @param array $optionsFacetedData
* @return int
*/
private function getOptionCount($value, $optionsFacetedData)
{
return isset($optionsFacetedData[$value]['count'])
? (int)$optionsFacetedData[$value]['count']
: 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ function setPostcodeOptional(zipElement, country) {
zipElement.removeClassName('required-entry');
}
zipElement.up('div.field').removeClassName('required');
zipElement.up('div.field').removeClassName('_required');
} else {
zipElement.addClassName('required-entry');
zipElement.up('div.field').addClassName('required');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ public function clear()
$this->items = [];
$this->errorStatistics = [];
$this->invalidRows = [];
$this->skippedRows = [];

return $this;
}
Expand Down
1 change: 0 additions & 1 deletion app/code/Magento/NewRelicReporting/etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="Magento\Framework\Module\ModuleListInterface" type="Magento\Framework\Module\ModuleList" />
<type name="Magento\NewRelicReporting\Model\Module\Collect">
<arguments>
<argument name="fullModuleList" xsi:type="object">Magento\Framework\Module\FullModuleList</argument>
Expand Down
9 changes: 5 additions & 4 deletions app/code/Magento/Quote/Model/Quote.php
Original file line number Diff line number Diff line change
Expand Up @@ -1626,10 +1626,11 @@ public function addProduct(

// collect errors instead of throwing first one
if ($item->getHasError()) {
$message = $item->getMessage();
if (!in_array($message, $errors)) {
// filter duplicate messages
$errors[] = $message;
foreach ($item->getMessage(false) as $message) {
if (!in_array($message, $errors)) {
// filter duplicate messages
$errors[] = $message;
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

<label class="admin__field-label" for="p_method_<?php /* @escapeNotVerified */ echo $_code ?>"><?php echo $block->escapeHtml($_method->getTitle()) ?></label>
</dt>
<dd class="admin__payment-method-wapper">
<dd class="admin__payment-method-wrapper">
<?php /* @escapeNotVerified */ echo $block->getChildHtml('payment.method.' . $_code) ?>
</dd>
<?php endforeach; ?>
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Swatches/Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ public function getSwatchesByOptionsId(array $optionIds)
foreach ($swatchCollection as $item) {
if ($item['type'] != Swatch::SWATCH_TYPE_TEXTUAL) {
$swatches[$item['option_id']] = $item->getData();
} elseif ($item['store_id'] == $currentStoreId && $item['value']) {
} elseif ($item['store_id'] == $currentStoreId && $item['value'] != '') {
$fallbackValues[$item['option_id']][$currentStoreId] = $item->getData();
} elseif ($item['store_id'] == self::DEFAULT_STORE_ID) {
$fallbackValues[$item['option_id']][self::DEFAULT_STORE_ID] = $item->getData();
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Swatches/Model/Plugin/EavAttribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ protected function isOptionsValid(array $options, Attribute $attribute)
if ($this->isOptionForDelete($attribute, $optionId)) {
continue;
}
if (empty($option[0])) {
if (!isset($option[0]) || $option[0] === '') {
return false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// Order Payment & Shipping Information
// ---------------------------------------------

.admin__payment-method-wapper {
.admin__payment-method-wrapper {
margin: 0;
.admin__field {
margin-left: 0;
Expand Down

0 comments on commit f7a552f

Please sign in to comment.