-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#7768: Adding 'is_saleable' attribute to sort of product collection c…
…auses exception and adding 'is_salable' has no effect.
- Loading branch information
1 parent
3c59bd5
commit 6267566
Showing
4 changed files
with
117 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
...egration/testsuite/Magento/Catalog/_files/multiple_products_with_non_saleable_product.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
/** @var $product \Magento\Catalog\Model\Product */ | ||
$product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(\Magento\Catalog\Model\Product::class); | ||
$product->isObjectNew(true); | ||
$product->setTypeId(\Magento\Catalog\Model\Product\Type::TYPE_SIMPLE) | ||
->setAttributeSetId(4) | ||
->setName('Simple Product') | ||
->setSku('simple_saleable') | ||
->setTaxClassId('none') | ||
->setDescription('description') | ||
->setShortDescription('short description') | ||
->setOptionsContainer('container1') | ||
->setMsrpDisplayActualPriceType(\Magento\Msrp\Model\Product\Attribute\Source\Type::TYPE_IN_CART) | ||
->setPrice(10) | ||
->setWeight(1) | ||
->setMetaTitle('meta title') | ||
->setMetaKeyword('meta keyword') | ||
->setMetaDescription('meta description') | ||
->setVisibility(\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH) | ||
->setStatus(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED) | ||
->setWebsiteIds([1]) | ||
->setCateroryIds([]) | ||
->setStockData(['use_config_manage_stock' => 1, 'qty' => 100, 'is_qty_decimal' => 0, 'is_in_stock' => 1]) | ||
->save(); | ||
|
||
$product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(\Magento\Catalog\Model\Product::class); | ||
$product->isObjectNew(true); | ||
$product->setTypeId(\Magento\Catalog\Model\Product\Type::TYPE_SIMPLE) | ||
->setAttributeSetId(4) | ||
->setName('Simple Product2') | ||
->setSku('simple_not_saleable') | ||
->setTaxClassId('none') | ||
->setDescription('description') | ||
->setShortDescription('short description') | ||
->setOptionsContainer('container1') | ||
->setMsrpDisplayActualPriceType(\Magento\Msrp\Model\Product\Attribute\Source\Type::TYPE_ON_GESTURE) | ||
->setPrice(20) | ||
->setWeight(1) | ||
->setMetaTitle('meta title') | ||
->setMetaKeyword('meta keyword') | ||
->setMetaDescription('meta description') | ||
->setVisibility(\Magento\Catalog\Model\Product\Visibility::VISIBILITY_IN_CATALOG) | ||
->setStatus(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED) | ||
->setWebsiteIds([1]) | ||
->setCateroryIds([]) | ||
->setStockData(['use_config_manage_stock' => 1, 'qty' => 50, 'is_qty_decimal' => 0, 'is_in_stock' => 0]) | ||
->save(); |
28 changes: 28 additions & 0 deletions
28
...testsuite/Magento/Catalog/_files/multiple_products_with_non_saleable_product_rollback.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); | ||
|
||
/** @var \Magento\Framework\Registry $registry */ | ||
$registry = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(\Magento\Framework\Registry::class); | ||
|
||
$registry->unregister('isSecureArea'); | ||
$registry->register('isSecureArea', true); | ||
|
||
/** @var \Magento\Catalog\Api\ProductRepositoryInterface $productRepository */ | ||
$productRepository = $objectManager->create(\Magento\Catalog\Api\ProductRepositoryInterface::class); | ||
|
||
foreach (['simple_saleable', 'simple_not_saleable'] as $sku) { | ||
try { | ||
$product = $productRepository->get($sku, false, null, true); | ||
$productRepository->delete($product); | ||
} catch (\Magento\Framework\Exception\NoSuchEntityException $exception) { | ||
//Product already removed | ||
} | ||
} | ||
|
||
$registry->unregister('isSecureArea'); | ||
$registry->register('isSecureArea', false); |