Skip to content

Commit

Permalink
🔃 [EngCom] Public Pull Requests - 2.2-develop
Browse files Browse the repository at this point in the history
Accepted Public Pull Requests:
 - #13341: Bugfix/13327 ui active state not removed from previous menu item (by @arnoudhgz)
 - #13364: [Backport 2.2] In checkout->multishipping-> new addres clean region when select country without dropdown for states  (by @enriquei4)
 - #12650: Add fallback for Product_links position attribute if not set in request (by @mohammedsalem)


Fixed GitHub Issues:
 - #13327: Menu ui-state-active not removed from previous opened menu item (reported by @arnoudhgz) has been fixed in #13341 by @arnoudhgz in 2.2-develop branch
   Related commits:
     1. 5714ffd
     2. 5773225

 - #8621: M2.1 Multishipping Checkout step New Address - Old State is saved when country is changed (reported by @ajaysinghrana23) has been fixed in #13364 by @enriquei4 in 2.2-develop branch
   Related commits:
     1. 1b2a17c
  • Loading branch information
magento-engcom-team authored Jan 31, 2018
2 parents 04d90c2 + 6c0fbaf commit 3572ee9
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 3 deletions.
48 changes: 45 additions & 3 deletions app/code/Magento/Catalog/Model/Product/Link/SaveHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,27 @@ class SaveHandler
private $linkResource;

/**
* @var linkTypeProvider
*/
private $linkTypeProvider;

/**
* SaveHandler constructor.
* @param MetadataPool $metadataPool
* @param Link $linkResource
* @param ProductLinkRepositoryInterface $productLinkRepository
* @param \Magento\Catalog\Model\Product\LinkTypeProvider $linkTypeProvider
*/
public function __construct(
MetadataPool $metadataPool,
Link $linkResource,
ProductLinkRepositoryInterface $productLinkRepository
ProductLinkRepositoryInterface $productLinkRepository,
\Magento\Catalog\Model\Product\LinkTypeProvider $linkTypeProvider
) {
$this->metadataPool = $metadataPool;
$this->linkResource = $linkResource;
$this->productLinkRepository = $productLinkRepository;
$this->linkTypeProvider = $linkTypeProvider;
}

/**
Expand All @@ -55,17 +64,50 @@ public function execute($entityType, $entity)
{
$link = $entity->getData($this->metadataPool->getMetadata($entityType)->getLinkField());
if ($this->linkResource->hasProductLinks($link)) {
/** @var \Magento\Catalog\Api\Data\ProductInterface $entity*/
/** @var \Magento\Catalog\Api\Data\ProductInterface $entity */
foreach ($this->productLinkRepository->getList($entity) as $link) {
$this->productLinkRepository->delete($link);
}
}
$productLinks = $entity->getProductLinks();

// Build links per type
$linksByType = [];
foreach ($entity->getProductLinks() as $link) {
$linksByType[$link->getLinkType()][] = $link;
}

// Set array position as a fallback position if necessary
foreach ($linksByType as $linkType => $links) {
if (!$this->hasPosition($links)) {
array_walk($linksByType[$linkType], function ($productLink, $position) {
$productLink->setPosition(++$position);
});
}
}

// Flatten multi-dimensional linksByType in ProductLinks
$productLinks = array_reduce($linksByType, 'array_merge', []);

if (count($productLinks) > 0) {
foreach ($entity->getProductLinks() as $link) {
$this->productLinkRepository->save($link);
}
}
return $entity;
}

/**
* Check if at least one link without position
* @param array $links
* @return bool
*/
private function hasPosition(array $links)
{
foreach ($links as $link) {
if (!array_key_exists('position', $link->getData())) {
return false;
}
}
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@ define([
regionInput.hide();
label.attr('for', regionList.attr('id'));
} else {
this._removeSelectOptions(regionList);

if (this.options.isRegionRequired) {
regionInput.addClass('required-entry').removeAttr('disabled');
requiredLabel.addClass('required');
Expand Down
3 changes: 3 additions & 0 deletions lib/web/mage/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,9 @@ define([
return;
}

// remove the active state class from the siblings
this.active.siblings().children('.ui-state-active').removeClass('ui-state-active');

this._open(newItem.parent());

// Delay so Firefox will not hide activedescendant change in expanding submenu from AT
Expand Down

0 comments on commit 3572ee9

Please sign in to comment.