Skip to content

SetFromDate and SetToDate not working correct in 2.4.1 when creating a Rule programatically #31453

Open
@chequille

Description

@chequille

Summary (*)

Magento 2.4-develop
I do have a module, where I am generating sales rules programatically. This module worked without andy problems in Magento Version 2.3.5.
No I am testing Version 2.4.1 and found, that SetFromDate and SetToDate is not working correct anymore.

Examples (*)

Here the relevant code lines I am using:

`		$rule =$this->rule;
		$rule->setName($name) // Rules name
		->setDescription('Wertgutschein '.$name )
		->setIsAdvanced(true)
		->setStopRulesProcessing(false)
		->setCustomerGroupIds([0, 1, 2, 3])
		->setWebsiteIds([1])
		->setUseAutoGeneration(0)    // If want to auto generate
		->setCouponType(RuleInterface::COUPON_TYPE_SPECIFIC_COUPON)
		->setSimpleAction(RuleInterface::DISCOUNT_ACTION_FIXED_AMOUNT_FOR_CART)
		->setUsesPerCoupon(1)
		->setDiscountAmount($amount)
		->setFromDate('2020-12-24') //Format YYYY-MM-DD
 		->setToDate('2039-04-14') //Format YYYY-MM-DD
		->setIsActive(true);
		$resultRules = $this->RuleRepository->save($rule);
`

The rule is generated, no problem, but the dates does show the following:
grafik
image

Proposed solution

Metadata

Metadata

Assignees

Labels

Area: PricingComponent: SalesRuleIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedPriority: P2A defect with this priority could have functionality issues which are not to expectations.Progress: dev in progressReported on 2.4.1Indicates original Magento version for the Issue report.Reproduced on 2.4.xThe issue has been reproduced on latest 2.4-develop branchTriage: Dev.ExperienceIssue related to Developer Experience and needs help with Triage to Confirm or Reject it

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions