Skip to content

Commit f06e0d9

Browse files
committed
Merge pull request #77 from magento-goinc/pr_branch
[SWAT] Bugfixes
2 parents c2bbe72 + 1c42c28 commit f06e0d9

File tree

81 files changed

+234
-211
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+234
-211
lines changed

app/code/Magento/Catalog/Api/AttributeSetFinderInterface.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
*/
77
namespace Magento\Catalog\Api;
88

9+
/**
10+
* Interface AttributeSetFinderInterface
11+
* @api
12+
*/
913
interface AttributeSetFinderInterface
1014
{
1115
/**

app/code/Magento/Catalog/Api/Data/CategoryProductSearchResultInterface.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
*/
77
namespace Magento\Catalog\Api\Data;
88

9+
/**
10+
* Interface CategoryProductSearchResultInterface
11+
* @api
12+
*/
913
interface CategoryProductSearchResultInterface extends \Magento\Framework\Api\SearchResultsInterface
1014
{
1115
/**

app/code/Magento/Catalog/Api/Data/ProductOptionInterface.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
/**
1111
* Product option interface
12+
* @api
1213
*/
1314
interface ProductOptionInterface extends ExtensibleDataInterface
1415
{

app/code/Magento/Catalog/Api/ProductWebsiteLinkRepositoryInterface.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66

77
namespace Magento\Catalog\Api;
88

9+
/**
10+
* Interface ProductWebsiteLinkRepositoryInterface
11+
* @api
12+
*/
913
interface ProductWebsiteLinkRepositoryInterface
1014
{
1115
/**

app/code/Magento/CatalogImportExport/Model/Import/Product.php

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@
1616
use Magento\ImportExport\Model\Import;
1717
use Magento\ImportExport\Model\Import\ErrorProcessing\ProcessingError;
1818
use Magento\ImportExport\Model\Import\ErrorProcessing\ProcessingErrorAggregatorInterface;
19-
use Magento\Catalog\Api\Data\ProductInterface;
2019
use Magento\ImportExport\Model\Import\Entity\AbstractEntity;
21-
20+
use Magento\Catalog\Model\Product\Visibility;
2221
/**
2322
* Import entity product model
2423
* @SuppressWarnings(PHPMD.TooManyFields)
@@ -104,6 +103,11 @@ class Product extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity
104103
*/
105104
const COL_CATEGORY = 'categories';
106105

106+
/**
107+
* Column product visibility.
108+
*/
109+
const COL_VISIBILITY = 'visibility';
110+
107111
/**
108112
* Column product sku.
109113
*/
@@ -2286,7 +2290,8 @@ public function validateRow(array $rowData, $rowNum)
22862290
}
22872291
// validate custom options
22882292
$this->getOptionEntity()->validateRow($rowData, $rowNum);
2289-
if (!empty($rowData[self::URL_KEY]) || !empty($rowData[self::COL_NAME])) {
2293+
2294+
if ($this->isNeedToValidateUrlKey($rowData)) {
22902295
$urlKey = $this->getUrlKey($rowData);
22912296
$storeCodes = empty($rowData[self::COL_STORE_VIEW_CODE])
22922297
? array_flip($this->storeResolver->getStoreCodeToId())
@@ -2308,6 +2313,18 @@ public function validateRow(array $rowData, $rowNum)
23082313
return !$this->getErrorAggregator()->isRowInvalid($rowNum);
23092314
}
23102315

2316+
/**
2317+
* @param array $rowData
2318+
* @return bool
2319+
*/
2320+
private function isNeedToValidateUrlKey($rowData)
2321+
{
2322+
return (!empty($rowData[self::URL_KEY]) || !empty($rowData[self::COL_NAME]))
2323+
&& (empty($rowData[self::COL_VISIBILITY])
2324+
|| $rowData[self::COL_VISIBILITY]
2325+
!== (string)Visibility::getOptionArray()[Visibility::VISIBILITY_NOT_VISIBLE]);
2326+
}
2327+
23112328
/**
23122329
* Prepare new SKU data
23132330
*

app/code/Magento/CatalogRule/Api/CatalogRuleRepositoryInterface.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,34 +5,34 @@
55
*/
66
namespace Magento\CatalogRule\Api;
77

8+
/**
9+
* Interface CatalogRuleRepositoryInterface
10+
* @api
11+
*/
812
interface CatalogRuleRepositoryInterface
913
{
1014
/**
11-
* @api
1215
* @param \Magento\CatalogRule\Api\Data\RuleInterface $rule
1316
* @return \Magento\CatalogRule\Api\Data\RuleInterface
1417
* @throws \Magento\Framework\Exception\CouldNotSaveException
1518
*/
1619
public function save(\Magento\CatalogRule\Api\Data\RuleInterface $rule);
1720

1821
/**
19-
* @api
2022
* @param int $ruleId
2123
* @return \Magento\CatalogRule\Api\Data\RuleInterface
2224
* @throws \Magento\Framework\Exception\NoSuchEntityException
2325
*/
2426
public function get($ruleId);
2527

2628
/**
27-
* @api
2829
* @param \Magento\CatalogRule\Api\Data\RuleInterface $rule
2930
* @return bool
3031
* @throws \Magento\Framework\Exception\CouldNotDeleteException
3132
*/
3233
public function delete(\Magento\CatalogRule\Api\Data\RuleInterface $rule);
3334

3435
/**
35-
* @api
3636
* @param int $ruleId
3737
* @return bool
3838
* @throws \Magento\Framework\Exception\CouldNotDeleteException

app/code/Magento/CatalogUrlRewrite/Model/Category/Plugin/Store/Group.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ protected function generateProductUrls($websiteId, $originWebsiteId)
113113
$collection = $this->productFactory->create()
114114
->getCollection()
115115
->addCategoryIds()
116-
->addAttributeToSelect(['name', 'url_path', 'url_key'])
116+
->addAttributeToSelect(['name', 'url_path', 'url_key', 'visibility'])
117117
->addWebsiteFilter($websiteIds);
118118
foreach ($collection as $product) {
119119
/** @var \Magento\Catalog\Model\Product $product */

app/code/Magento/CatalogUrlRewrite/Model/Category/Plugin/Store/View.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ protected function generateProductUrls($websiteId, $originWebsiteId, $storeId)
100100
$collection = $this->productFactory->create()
101101
->getCollection()
102102
->addCategoryIds()
103-
->addAttributeToSelect(['name', 'url_path', 'url_key'])
103+
->addAttributeToSelect(['name', 'url_path', 'url_key', 'visibility'])
104104
->addWebsiteFilter($websiteIds);
105105
foreach ($collection as $product) {
106106
$product->setStoreId($storeId);

app/code/Magento/CatalogUrlRewrite/Model/ProductUrlRewriteGenerator.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use Magento\CatalogUrlRewrite\Model\Product\AnchorUrlRewriteGenerator;
1313
use Magento\CatalogUrlRewrite\Service\V1\StoreViewService;
1414
use Magento\Store\Model\Store;
15+
use Magento\Catalog\Model\Product\Visibility;
1516

1617
/**
1718
* Class ProductUrlRewriteGenerator
@@ -98,6 +99,10 @@ private function getAnchorUrlRewriteGenerator()
9899
*/
99100
public function generate(Product $product)
100101
{
102+
if ($product->getVisibility() == Visibility::VISIBILITY_NOT_VISIBLE) {
103+
return [];
104+
}
105+
101106
$this->product = $product;
102107
$storeId = $this->product->getStoreId();
103108

app/code/Magento/CatalogUrlRewrite/Observer/AfterImportDataObserver.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
use Magento\UrlRewrite\Model\OptionProvider;
2020
use Magento\UrlRewrite\Model\UrlFinderInterface;
2121
use Magento\Framework\Event\ObserverInterface;
22-
22+
use Magento\Catalog\Model\Product\Visibility;
2323
/**
2424
* Class AfterImportDataObserver
2525
*
@@ -93,6 +93,7 @@ class AfterImportDataObserver implements ObserverInterface
9393
'url_key',
9494
'url_path',
9595
'name',
96+
'visibility',
9697
];
9798

9899
/**
@@ -221,6 +222,9 @@ protected function setStoreToProduct(\Magento\Catalog\Model\Product $product, ar
221222
*/
222223
protected function addProductToImport($product, $storeId)
223224
{
225+
if ($product->getVisibility() == (string)Visibility::getOptionArray()[Visibility::VISIBILITY_NOT_VISIBLE]) {
226+
return $this;
227+
}
224228
if (!isset($this->products[$product->getId()])) {
225229
$this->products[$product->getId()] = [];
226230
}
@@ -321,6 +325,9 @@ protected function categoriesUrlRewriteGenerate()
321325
foreach ($productsByStores as $storeId => $product) {
322326
foreach ($this->categoryCache[$productId] as $categoryId) {
323327
$category = $this->import->getCategoryProcessor()->getCategoryById($categoryId);
328+
if ($category->getParentId() == Category::TREE_ROOT_ID) {
329+
continue;
330+
}
324331
$requestPath = $this->productUrlPathGenerator->getUrlPathWithSuffix($product, $storeId, $category);
325332
$urls[] = $this->urlRewriteFactory->create()
326333
->setEntityType(ProductUrlRewriteGenerator::ENTITY_TYPE)

0 commit comments

Comments
 (0)