Skip to content
This repository has been archived by the owner on Apr 29, 2019. It is now read-only.

Commit

Permalink
🔃 [EngCom] Public Pull Requests - 2.3-develop
Browse files Browse the repository at this point in the history
Accepted Public Pull Requests:
 - magento/magento2#15480: [Forwardport] Prevent not category links in breadcrumbs at product page #14994 (by @vovayatsyuk)
 - magento/magento2#14700: [2.3] Optimize ID to SKU lookup of tier prices (by @toddbc)
  • Loading branch information
magento-engcom-team authored May 25, 2018
2 parents bed17e0 + b478457 commit 166dd61
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 10 deletions.
18 changes: 10 additions & 8 deletions app/code/Magento/Catalog/Model/Product/Price/TierPriceStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,10 @@ private function getExistingPrices(array $skus, $groupBySku = false)
$rawPrices = $this->tierPricePersistence->get($ids);
$prices = [];

$linkField = $this->tierPricePersistence->getEntityLinkField();
$skuByIdLookup = $this->buildSkuByIdLookup($skus);
foreach ($rawPrices as $rawPrice) {
$sku = $this->retrieveSkuById($rawPrice[$this->tierPricePersistence->getEntityLinkField()], $skus);
$sku = $skuByIdLookup[$rawPrice[$linkField]];
$price = $this->tierPriceFactory->create($rawPrice, $sku);
if ($groupBySku) {
$prices[$sku][] = $price;
Expand Down Expand Up @@ -300,21 +302,21 @@ private function isCorrectPriceValue(array $existingPrice, array $price)
}

/**
* Retrieve SKU by product ID.
* Generate lookup to retrieve SKU by product ID.
*
* @param int $id
* @param array $skus
* @return string|null
* @return array
*/
private function retrieveSkuById($id, $skus)
private function buildSkuByIdLookup($skus)
{
$lookup = [];
foreach ($this->productIdLocator->retrieveProductIdsBySkus($skus) as $sku => $ids) {
if (isset($ids[$id])) {
return $sku;
foreach (array_keys($ids) as $id) {
$lookup[$id] = $sku;
}
}

return null;
return $lookup;
}

/**
Expand Down
1 change: 1 addition & 0 deletions app/code/Magento/Catalog/Plugin/Block/Topmenu.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ private function getCategoryAsArray($category, $currentCategory, $isParentActive
'url' => $this->catalogCategory->getCategoryUrl($category),
'has_active' => in_array((string)$category->getId(), explode('/', $currentCategory->getPath()), true),
'is_active' => $category->getId() == $currentCategory->getId(),
'is_category' => true,
'is_parent_active' => $isParentActive
];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ define([
categoryUrlSuffix: '',
useCategoryPathInUrl: false,
product: '',
categoryItemSelector: '.category-item',
menuContainer: '[data-action="navigation"] > ul'
},

Expand Down Expand Up @@ -163,7 +164,10 @@ define([
categoryMenuItem = null;

if (categoryUrl && menu.length) {
categoryMenuItem = menu.find('a[href="' + categoryUrl + '"]');
categoryMenuItem = menu.find(
this.options.categoryItemSelector +
' > a[href="' + categoryUrl + '"]'
);
}

return categoryMenuItem;
Expand Down
4 changes: 4 additions & 0 deletions app/code/Magento/Theme/Block/Html/Topmenu.php
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,10 @@ protected function _getMenuItemClasses(\Magento\Framework\Data\Tree\Node $item)
$classes[] = 'level' . $item->getLevel();
$classes[] = $item->getPositionClass();

if ($item->getIsCategory()) {
$classes[] = 'category-item';
}

if ($item->getIsFirst()) {
$classes[] = 'first';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ define([
'Magento_Theme/js/model/breadcrumb-list': jasmine.createSpyObj(['push'])
},
defaultContext = require.s.contexts._,
menuItem = $('<li class="level0"><a href="http://localhost.com/cat1.html" id="ui-id-3">Cat1</a></li>')[0],
menuItem = $(
'<li class="level0 category-item">' +
'<a href="http://localhost.com/cat1.html" id="ui-id-3">Cat1</a>' +
'</li>'
)[0],

/**
* Create context object.
Expand Down

0 comments on commit 166dd61

Please sign in to comment.