Skip to content

Commit a9ca041

Browse files
committed
MC-18057: Product doesn'y match by "Date" attribute condition
1 parent 0ba9615 commit a9ca041

File tree

2 files changed

+49
-3
lines changed

2 files changed

+49
-3
lines changed

dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_with_date_attribute.php

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@
1010

1111
$attribute->setData('is_used_for_promo_rules', 1);
1212

13-
/** @var $product \Magento\Catalog\Model\Product */
14-
$product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(\Magento\Catalog\Model\Product::class);
13+
/** @var ProductFactory $productFactory */
14+
$productFactory = $objectManager->get(Magento\Catalog\Model\ProductFactory::class);
15+
$product = $productFactory->create();
1516
$product->setTypeId(\Magento\Catalog\Model\Product\Type::TYPE_SIMPLE)
16-
->setAttributeSetId(4)
17+
->setAttributeSetId($installer->getAttributeSetId('catalog_product', 'Default'))
1718
->setWebsiteIds([1])
1819
->setName('Simple Product with date')
1920
->setSku('simple_with_date')
@@ -24,4 +25,37 @@
2425
->setCategoryIds([2])
2526
->setStockData(['use_config_manage_stock' => 1, 'qty' => 100, 'is_qty_decimal' => 0, 'is_in_stock' => 1])
2627
->setDateAttribute(date('Y-m-d'))
28+
->setUrlKey('simple_with_date')
29+
->save();
30+
31+
$product2 = $productFactory->create();
32+
$product2->setTypeId(\Magento\Catalog\Model\Product\Type::TYPE_SIMPLE)
33+
->setAttributeSetId($installer->getAttributeSetId('catalog_product', 'Default'))
34+
->setWebsiteIds([1])
35+
->setName('Simple Product with date -1')
36+
->setSku('simple_with_date2')
37+
->setPrice(10)
38+
->setDescription('Description with <b>html tag</b>')
39+
->setVisibility(\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH)
40+
->setStatus(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED)
41+
->setCategoryIds([2])
42+
->setStockData(['use_config_manage_stock' => 1, 'qty' => 100, 'is_qty_decimal' => 0, 'is_in_stock' => 1])
43+
->setDateAttribute(date('Y-m-d', strtotime(date('Y-m-d') . '-1 day')))
44+
->setUrlKey('simple_with_date2')
45+
->save();
46+
47+
$product3 = $productFactory->create();
48+
$product3->setTypeId(\Magento\Catalog\Model\Product\Type::TYPE_SIMPLE)
49+
->setAttributeSetId($installer->getAttributeSetId('catalog_product', 'Default'))
50+
->setWebsiteIds([1])
51+
->setName('Simple Product with date +1')
52+
->setSku('simple_with_date3')
53+
->setPrice(10)
54+
->setDescription('Description with <b>html tag</b>')
55+
->setVisibility(\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH)
56+
->setStatus(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED)
57+
->setCategoryIds([2])
58+
->setStockData(['use_config_manage_stock' => 1, 'qty' => 100, 'is_qty_decimal' => 0, 'is_in_stock' => 1])
59+
->setDateAttribute(date('Y-m-d', strtotime(date('Y-m-d') . '+1 day')))
60+
->setUrlKey('simple_with_date3')
2761
->save();

dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_with_date_attribute_rollback.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,18 @@
2626
} catch (NoSuchEntityException $e) {
2727
}
2828

29+
try {
30+
$product = $productRepository->get('simple_with_date2', false, null, true);
31+
$productRepository->delete($product);
32+
} catch (NoSuchEntityException $e) {
33+
}
34+
35+
try {
36+
$product = $productRepository->get('simple_with_date3', false, null, true);
37+
$productRepository->delete($product);
38+
} catch (NoSuchEntityException $e) {
39+
}
40+
2941
$registry->unregister('isSecureArea');
3042
$registry->register('isSecureArea', false);
3143

0 commit comments

Comments
 (0)