Skip to content

Commit 0fc68f9

Browse files
committed
MAGETWO-93776: [Forwardport] Stabilization
1 parent 8b94671 commit 0fc68f9

File tree

2 files changed

+80
-0
lines changed

2 files changed

+80
-0
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
/** @var $product \Magento\Catalog\Model\Product */
8+
$product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(\Magento\Catalog\Model\Product::class);
9+
$product->isObjectNew(true);
10+
$product->setTypeId(\Magento\Catalog\Model\Product\Type::TYPE_SIMPLE)
11+
->setAttributeSetId(4)
12+
->setName('Simple Product')
13+
->setSku('simple_saleable')
14+
->setTaxClassId('none')
15+
->setDescription('description')
16+
->setShortDescription('short description')
17+
->setOptionsContainer('container1')
18+
->setMsrpDisplayActualPriceType(\Magento\Msrp\Model\Product\Attribute\Source\Type::TYPE_IN_CART)
19+
->setPrice(10)
20+
->setWeight(1)
21+
->setMetaTitle('meta title')
22+
->setMetaKeyword('meta keyword')
23+
->setMetaDescription('meta description')
24+
->setVisibility(\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH)
25+
->setStatus(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED)
26+
->setWebsiteIds([1])
27+
->setCategoryIds([])
28+
->setStockData(['use_config_manage_stock' => 1, 'qty' => 100, 'is_qty_decimal' => 0, 'is_in_stock' => 1])
29+
->save();
30+
31+
$product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(\Magento\Catalog\Model\Product::class);
32+
$product->isObjectNew(true);
33+
$product->setTypeId(\Magento\Catalog\Model\Product\Type::TYPE_SIMPLE)
34+
->setAttributeSetId(4)
35+
->setName('Simple Product2')
36+
->setSku('simple_not_saleable')
37+
->setTaxClassId('none')
38+
->setDescription('description')
39+
->setShortDescription('short description')
40+
->setOptionsContainer('container1')
41+
->setMsrpDisplayActualPriceType(\Magento\Msrp\Model\Product\Attribute\Source\Type::TYPE_ON_GESTURE)
42+
->setPrice(20)
43+
->setWeight(1)
44+
->setMetaTitle('meta title')
45+
->setMetaKeyword('meta keyword')
46+
->setMetaDescription('meta description')
47+
->setVisibility(\Magento\Catalog\Model\Product\Visibility::VISIBILITY_IN_CATALOG)
48+
->setStatus(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED)
49+
->setWebsiteIds([1])
50+
->setCategoryIds([])
51+
->setStockData(['use_config_manage_stock' => 1, 'qty' => 50, 'is_qty_decimal' => 0, 'is_in_stock' => 0])
52+
->save();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
8+
9+
/** @var \Magento\Framework\Registry $registry */
10+
$registry = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(\Magento\Framework\Registry::class);
11+
12+
$registry->unregister('isSecureArea');
13+
$registry->register('isSecureArea', true);
14+
15+
/** @var \Magento\Catalog\Api\ProductRepositoryInterface $productRepository */
16+
$productRepository = $objectManager->create(\Magento\Catalog\Api\ProductRepositoryInterface::class);
17+
18+
foreach (['simple_saleable', 'simple_not_saleable'] as $sku) {
19+
try {
20+
$product = $productRepository->get($sku, false, null, true);
21+
$productRepository->delete($product);
22+
} catch (\Magento\Framework\Exception\NoSuchEntityException $exception) {
23+
//Product already removed
24+
}
25+
}
26+
27+
$registry->unregister('isSecureArea');
28+
$registry->register('isSecureArea', false);

0 commit comments

Comments
 (0)