Skip to content

Commit

Permalink
Merge pull request #3463 from magento-epam/EPAM-PR-18
Browse files Browse the repository at this point in the history
Fixed bugs:
MAGETWO-91609 Problems with operator more/less in the "catalog Products List" widget
MAGETWO-91650 Translation not working for product alerts
MAGETWO-91649 #13513: Magento ignore store-level url_key of child category in URL rewrite process for global scope
MAGETWO-91657 Advanced pricing the bulk discounts by percentage returns error when set
MAGETWO-91733 Unusual behavior with the persistent shopping cart after the session is expired
MAGETWO-91602 Visual Merchandiser incorrectly displays/sorts configurable product price in Tile view
MAGETWO-91764 Frontend base url https results in admin too many redirects #8800
MAGETWO-91633 Grouped Products: Associated Products Can't Be Sorted Between Pages
MAGETWO-91751 Apostrophe displays as code in the text field box
MAGETWO-58210 [GitHub] Magento 2.0.7 Import Products sets default behaviour as append, need add_update #6193
MAGETWO-91711 Unable to delete downloadable product links if sample links are not deleted
MAGETWO-91569 Special characters in CSV return error: General system exception happened
MAGETWO-91684 Issue with Newsletter subscriptions
MAGETWO-91750 Multiselect attribute values is not searchable under Quick Search when more than one value is selected
MAGETWO-91636 Tooltip Position on Mobile out of view range
  • Loading branch information
rganin authored Nov 19, 2018
2 parents 4126ffc + 6e809ea commit 069d5cd
Show file tree
Hide file tree
Showing 53 changed files with 1,614 additions and 308 deletions.
38 changes: 18 additions & 20 deletions app/code/Magento/Backend/Model/AdminPathConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,39 +48,37 @@ public function __construct(
}

/**
* {@inheritdoc}
*
* @param \Magento\Framework\App\RequestInterface $request
* @return string
* @inheritdoc
*/
public function getCurrentSecureUrl(\Magento\Framework\App\RequestInterface $request)
{
return $this->url->getBaseUrl('link', true) . ltrim($request->getPathInfo(), '/');
}

/**
* {@inheritdoc}
*
* @param string $path
* @return bool
* @inheritdoc
*/
public function shouldBeSecure($path)
{
return parse_url(
(string)$this->coreConfig->getValue(Store::XML_PATH_UNSECURE_BASE_URL, 'default'),
PHP_URL_SCHEME
) === 'https'
|| $this->backendConfig->isSetFlag(Store::XML_PATH_SECURE_IN_ADMINHTML)
&& parse_url(
(string)$this->coreConfig->getValue(Store::XML_PATH_SECURE_BASE_URL, 'default'),
PHP_URL_SCHEME
) === 'https';
$baseUrl = (string)$this->coreConfig->getValue(Store::XML_PATH_UNSECURE_BASE_URL, 'default');
if (parse_url($baseUrl, PHP_URL_SCHEME) === 'https') {
return true;
}

if ($this->backendConfig->isSetFlag(Store::XML_PATH_SECURE_IN_ADMINHTML)) {
if ($this->backendConfig->isSetFlag('admin/url/use_custom')) {
$adminBaseUrl = (string)$this->coreConfig->getValue('admin/url/custom', 'default');
} else {
$adminBaseUrl = (string)$this->coreConfig->getValue(Store::XML_PATH_SECURE_BASE_URL, 'default');
}
return parse_url($adminBaseUrl, PHP_URL_SCHEME) === 'https';
}

return false;
}

/**
* {@inheritdoc}
*
* @return string
* @inheritdoc
*/
public function getDefaultPath()
{
Expand Down
44 changes: 31 additions & 13 deletions app/code/Magento/Backend/Test/Unit/Model/AdminPathConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,35 @@ public function testGetCurrentSecureUrl()
* @param $unsecureBaseUrl
* @param $useSecureInAdmin
* @param $secureBaseUrl
* @param $useCustomUrl
* @param $customUrl
* @param $expected
* @dataProvider shouldBeSecureDataProvider
*/
public function testShouldBeSecure($unsecureBaseUrl, $useSecureInAdmin, $secureBaseUrl, $expected)
{
$coreConfigValueMap = [
public function testShouldBeSecure(
$unsecureBaseUrl,
$useSecureInAdmin,
$secureBaseUrl,
$useCustomUrl,
$customUrl,
$expected
) {
$coreConfigValueMap = $this->returnValueMap([
[\Magento\Store\Model\Store::XML_PATH_UNSECURE_BASE_URL, 'default', null, $unsecureBaseUrl],
[\Magento\Store\Model\Store::XML_PATH_SECURE_BASE_URL, 'default', null, $secureBaseUrl],
];
$this->coreConfig->expects($this->any())->method('getValue')->will($this->returnValueMap($coreConfigValueMap));
$this->backendConfig->expects($this->any())->method('isSetFlag')->willReturn($useSecureInAdmin);
['admin/url/custom', 'default', null, $customUrl],
]);
$backendConfigFlagsMap = $this->returnValueMap([
[\Magento\Store\Model\Store::XML_PATH_SECURE_IN_ADMINHTML, $useSecureInAdmin],
['admin/url/use_custom', $useCustomUrl],
]);
$this->coreConfig->expects($this->atLeast(1))->method('getValue')
->will($coreConfigValueMap);
$this->coreConfig->expects($this->atMost(2))->method('getValue')
->will($coreConfigValueMap);

$this->backendConfig->expects($this->atMost(2))->method('isSetFlag')
->will($backendConfigFlagsMap);
$this->assertEquals($expected, $this->adminPathConfig->shouldBeSecure(''));
}

Expand All @@ -96,13 +114,13 @@ public function testShouldBeSecure($unsecureBaseUrl, $useSecureInAdmin, $secureB
public function shouldBeSecureDataProvider()
{
return [
['http://localhost/', false, 'default', false],
['http://localhost/', true, 'default', false],
['https://localhost/', false, 'default', true],
['https://localhost/', true, 'default', true],
['http://localhost/', false, 'https://localhost/', false],
['http://localhost/', true, 'https://localhost/', true],
['https://localhost/', true, 'https://localhost/', true],
['http://localhost/', false, 'default', false, '', false],
['http://localhost/', true, 'default', false, '', false],
['https://localhost/', false, 'default', false, '', true],
['https://localhost/', true, 'default', false, '', true],
['http://localhost/', false, 'https://localhost/', false, '', false],
['http://localhost/', true, 'https://localhost/', false, '', true],
['https://localhost/', true, 'https://localhost/', false, '', true],
];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,30 @@
</arguments>
<amOnPage url="{{AdminCategoryPage.page}}" stepKey="amOnCategoryPage"/>
<waitForPageLoad stepKey="waitForPageLoad1"/>
<click selector="{{AdminCategorySidebarTreeSection.categoryInTree(Category.Name)}}" stepKey="navigateToCreatedCategory" />
<click selector="{{AdminCategorySidebarTreeSection.expandAll}}" stepKey="expandAll"/>
<waitForPageLoad stepKey="waitForPageLoad2"/>
<click selector="{{AdminCategorySidebarTreeSection.categoryInTree(Category.Name)}}" stepKey="navigateToCreatedCategory" />
<waitForLoadingMaskToDisappear stepKey="waitForSpinner" />
</actionGroup>

<actionGroup name="ChangeSeoUrlKey">
<arguments>
<argument name="value" type="string"/>
</arguments>
<click selector="{{AdminCategorySEOSection.SectionHeader}}" stepKey="openSeoSection"/>
<fillField selector="{{AdminCategorySEOSection.UrlKeyInput}}" userInput="{{value}}" stepKey="enterURLKey"/>
<click selector="{{AdminCategoryMainActionsSection.SaveButton}}" stepKey="saveCategory"/>
<seeElement selector="{{AdminCategoryMessagesSection.SuccessMessage}}" stepKey="assertSuccessMessage"/>
</actionGroup>

<actionGroup name="ChangeSeoUrlKeyForSubCategory">
<arguments>
<argument name="value" type="string"/>
</arguments>
<click selector="{{AdminCategorySEOSection.SectionHeader}}" stepKey="openSeoSection"/>
<uncheckOption selector="{{AdminCategorySEOSection.UrlKeyDefaultValueCheckbox}}" stepKey="uncheckDefaultValue"/>
<fillField selector="{{AdminCategorySEOSection.UrlKeyInput}}" userInput="{{value}}" stepKey="enterURLKey"/>
<click selector="{{AdminCategoryMainActionsSection.SaveButton}}" stepKey="saveCategory"/>
<seeElement selector="{{AdminCategoryMessagesSection.SuccessMessage}}" stepKey="assertSuccessMessage"/>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,19 @@
<click selector="{{StorefrontCategoryMainSection.modeListButton}}" stepKey="switchCategoryViewToListMode"/>
<waitForElement selector="{{StorefrontCategoryMainSection.CategoryTitle}}" time="30" stepKey="waitForCategoryReload"/>
</actionGroup>

<actionGroup name="GoToSubCategoryPage">
<arguments>
<argument name="parentCategory"/>
<argument name="subCategory"/>
<argument name="urlPath" type="string"/>
</arguments>
<moveMouseOver selector="{{StorefrontHeaderSection.NavigationCategoryByName(parentCategory.name)}}" stepKey="moveMouseOnMainCategory"/>
<waitForElementVisible selector="{{StorefrontHeaderSection.NavigationCategoryByName(subCategory.name)}}" stepKey="waitForSubCategoryVisible"/>
<click selector="{{StorefrontHeaderSection.NavigationCategoryByName(subCategory.name)}}" stepKey="goToCategory"/>
<waitForPageLoad stepKey="waitForPageLoad"/>
<seeInCurrentUrl url="{{urlPath}}.html" stepKey="checkUrl"/>
<seeInTitle userInput="{{subCategory.name}}" stepKey="assertCategoryNameInTitle"/>
<see userInput="{{subCategory.name}}" selector="{{StorefrontCategoryMainSection.CategoryTitle}}" stepKey="assertCategoryName"/>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@
<element name="uploadImageFile" type="input" selector=".file-uploader-area>input"/>
<element name="imageFileName" type="text" selector=".file-uploader-filename"/>
<element name="removeImageButton" type="button" selector=".file-uploader-summary .action-remove"/>
<element name="AddCMSBlock" type="select" selector="//*[@name='landing_page']"/>
</section>
</sections>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
<section name="AdminCategoryDisplaySettingsSection">
<element name="settingsHeader" type="button" selector="//*[contains(text(),'Display Settings')]" timeout="30"/>
<element name="displayMode" type="button" selector="//*[@name='display_mode']"/>
</section>
</sections>
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function __construct(
}

/**
* {@inheritdoc}
* @inheritdoc
* @since 101.1.0
*/
public function modifyData(array $data)
Expand All @@ -54,8 +54,11 @@ public function modifyData(array $data)
}

/**
* {@inheritdoc}
* Add tier price info to meta array.
*
* @since 101.1.0
* @param array $meta
* @return array
*/
public function modifyMeta(array $meta)
{
Expand Down Expand Up @@ -150,8 +153,8 @@ private function getUpdatedTierPriceStructure(array $priceMeta)
'dataType' => Price::NAME,
'addbefore' => '%',
'validation' => [
'validate-number' => true,
'less-than-equals-to' => 100
'required-entry' => true,
'validate-positive-percent-decimal' => true
],
'visible' => $firstOption
&& $firstOption['value'] == ProductPriceOptionsInterface::VALUE_PERCENT,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -570,8 +570,8 @@ public function prepareProductIndex($indexData, $productData, $storeId)
}
}
foreach ($indexData as $entityId => $attributeData) {
foreach ($attributeData as $attributeId => $attributeValue) {
$value = $this->getAttributeValue($attributeId, $attributeValue, $storeId);
foreach ($attributeData as $attributeId => $attributeValues) {
$value = $this->getAttributeValue($attributeId, $attributeValues, $storeId);
if (!empty($value)) {
if (isset($index[$attributeId])) {
$index[$attributeId][$entityId] = $value;
Expand Down Expand Up @@ -602,16 +602,16 @@ public function prepareProductIndex($indexData, $productData, $storeId)
* Retrieve attribute source value for search
*
* @param int $attributeId
* @param mixed $valueId
* @param mixed $valueIds
* @param int $storeId
* @return string
*/
private function getAttributeValue($attributeId, $valueId, $storeId)
private function getAttributeValue($attributeId, $valueIds, $storeId)
{
$attribute = $this->getSearchableAttribute($attributeId);
$value = $this->engine->processAttributeValue($attribute, $valueId);
$value = $this->engine->processAttributeValue($attribute, $valueIds);
if (false !== $value) {
$optionValue = $this->getAttributeOptionValue($attributeId, $valueId, $storeId);
$optionValue = $this->getAttributeOptionValue($attributeId, $valueIds, $storeId);
if (null === $optionValue) {
$value = $this->filterAttributeValue($value);
} else {
Expand All @@ -626,13 +626,15 @@ private function getAttributeValue($attributeId, $valueId, $storeId)
* Get attribute option value
*
* @param int $attributeId
* @param int $valueId
* @param int|string $valueIds
* @param int $storeId
* @return null|string
*/
private function getAttributeOptionValue($attributeId, $valueId, $storeId)
private function getAttributeOptionValue($attributeId, $valueIds, $storeId)
{
$optionKey = $attributeId . '-' . $storeId;
$attributeValueIds = explode(',', $valueIds);
$attributeOptionValue = '';
if (!array_key_exists($optionKey, $this->attributeOptions)
) {
$attribute = $this->getSearchableAttribute($attributeId);
Expand All @@ -650,8 +652,12 @@ private function getAttributeOptionValue($attributeId, $valueId, $storeId)
$this->attributeOptions[$optionKey] = null;
}
}

return $this->attributeOptions[$optionKey][$valueId] ?? null;
foreach ($attributeValueIds as $attrValueId) {
if (isset($this->attributeOptions[$optionKey][$attrValueId])) {
$attributeOptionValue .= $this->attributeOptions[$optionKey][$attrValueId] . ' ';
}
}
return empty($attributeOptionValue) ? null : trim($attributeOptionValue);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@
use Magento\CatalogUrlRewrite\Model\CategoryUrlRewriteGenerator;
use Magento\UrlRewrite\Model\MergeDataProviderFactory;
use Magento\Framework\App\ObjectManager;
use Magento\Catalog\Api\CategoryRepositoryInterface;

/**
* Model for generate url rewrites for children categories
*/
class ChildrenUrlRewriteGenerator
{
/**
Expand All @@ -28,22 +32,31 @@ class ChildrenUrlRewriteGenerator
*/
private $mergeDataProviderPrototype;

/**
* @var CategoryRepositoryInterface
*/
private $categoryRepository;

/**
* @param \Magento\CatalogUrlRewrite\Model\Category\ChildrenCategoriesProvider $childrenCategoriesProvider
* @param \Magento\CatalogUrlRewrite\Model\CategoryUrlRewriteGeneratorFactory $categoryUrlRewriteGeneratorFactory
* @param \Magento\UrlRewrite\Model\MergeDataProviderFactory|null $mergeDataProviderFactory
* @param CategoryRepositoryInterface|null $categoryRepository
*/
public function __construct(
ChildrenCategoriesProvider $childrenCategoriesProvider,
CategoryUrlRewriteGeneratorFactory $categoryUrlRewriteGeneratorFactory,
MergeDataProviderFactory $mergeDataProviderFactory = null
MergeDataProviderFactory $mergeDataProviderFactory = null,
CategoryRepositoryInterface $categoryRepository = null
) {
$this->childrenCategoriesProvider = $childrenCategoriesProvider;
$this->categoryUrlRewriteGeneratorFactory = $categoryUrlRewriteGeneratorFactory;
if (!isset($mergeDataProviderFactory)) {
$mergeDataProviderFactory = ObjectManager::getInstance()->get(MergeDataProviderFactory::class);
}
$this->mergeDataProviderPrototype = $mergeDataProviderFactory->create();
$this->categoryRepository = $categoryRepository
?: ObjectManager::getInstance()->get(CategoryRepositoryInterface::class);
}

/**
Expand All @@ -53,18 +66,23 @@ public function __construct(
* @param \Magento\Catalog\Model\Category $category
* @param int|null $rootCategoryId
* @return \Magento\UrlRewrite\Service\V1\Data\UrlRewrite[]
* @throws \Magento\Framework\Exception\NoSuchEntityException
*/
public function generate($storeId, Category $category, $rootCategoryId = null)
{
$mergeDataProvider = clone $this->mergeDataProviderPrototype;
foreach ($this->childrenCategoriesProvider->getChildren($category, true) as $childCategory) {
$childCategory->setStoreId($storeId);
$childCategory->setData('save_rewrites_history', $category->getData('save_rewrites_history'));
/** @var CategoryUrlRewriteGenerator $categoryUrlRewriteGenerator */
$categoryUrlRewriteGenerator = $this->categoryUrlRewriteGeneratorFactory->create();
$mergeDataProvider->merge(
$categoryUrlRewriteGenerator->generate($childCategory, false, $rootCategoryId)
);
$childrenIds = $this->childrenCategoriesProvider->getChildrenIds($category, true);
if ($childrenIds) {
foreach ($childrenIds as $childId) {
/** @var Category $childCategory */
$childCategory = $this->categoryRepository->get($childId, $storeId);
$childCategory->setData('save_rewrites_history', $category->getData('save_rewrites_history'));
/** @var CategoryUrlRewriteGenerator $categoryUrlRewriteGenerator */
$categoryUrlRewriteGenerator = $this->categoryUrlRewriteGeneratorFactory->create();
$mergeDataProvider->merge(
$categoryUrlRewriteGenerator->generate($childCategory, false, $rootCategoryId)
);
}
}

return $mergeDataProvider->getData();
Expand Down
Loading

0 comments on commit 069d5cd

Please sign in to comment.