Skip to content

Commit e595a7b

Browse files
faraz-glsreenia806
authored andcommitted
AC-8753: Coupon quantity generation checks
* Code refinements and translations
1 parent 378065c commit e595a7b

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

app/code/Magento/SalesRule/Controller/Adminhtml/Promo/Quote/Generate.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -166,21 +166,21 @@ public function execute(): void
166166
self::XML_CONFIG_COUPON_QUANTITY_LIMIT,
167167
ScopeInterface::SCOPE_STORE
168168
);
169-
if ($data['quantity'] > 0 && $data['quantity'] > $couponQuantityLimit) {
169+
if ($data['quantity'] > 0 && $data['quantity'] <= $couponQuantityLimit) {
170+
$couponSpec = $this->generationSpecFactory->create(['data' => $data]);
171+
172+
$this->messagePublisher->publish('sales_rule.codegenerator', $couponSpec);
173+
$this->messageManager->addSuccessMessage(
174+
__('Message is added to queue, wait to get your coupons soon')
175+
);
176+
} else {
170177
// @codingStandardsIgnoreStart
171178
$this->messageManager->addErrorMessage(
172179
__(
173180
'Coupon quantity should be less than or equal to the coupon quantity in the store configuration.'
174181
)
175182
);
176183
// @codingStandardsIgnoreEnd
177-
} else {
178-
$couponSpec = $this->generationSpecFactory->create(['data' => $data]);
179-
180-
$this->messagePublisher->publish('sales_rule.codegenerator', $couponSpec);
181-
$this->messageManager->addSuccessMessage(
182-
__('Message is added to queue, wait to get your coupons soon')
183-
);
184184
}
185185
$this->_view->getLayout()->initMessages();
186186
$result['messages'] = $this->_view->getLayout()->getMessagesBlock()->getGroupedHtml();

app/code/Magento/SalesRule/etc/config.xml

100644100755
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<promo>
1111
<auto_generated_coupon_codes>
1212
<length>12</length>
13-
<quantity>250000</quantity>
13+
<quantity_limit>250000</quantity_limit>
1414
<format>1</format>
1515
</auto_generated_coupon_codes>
1616
</promo>

app/code/Magento/SalesRule/i18n/en_US.csv

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,3 +170,5 @@ Apply,Apply
170170
"When coupon quantity exceeds %1, the coupon code length must be minimum %2", "When coupon quantity exceeds %1, the coupon code length must be minimum %2"
171171
"Discount amount is distributed among subtotal and shipping amount. Cases when multiple discounts applied to shipping amount are not supported. The option is going to be removed in future releases.ly","Discount amount is distributed among subtotal and shipping amount. Cases when multiple discounts applied to shipping amount are not supported. The option is going to be removed in future releases."
172172
"Coupon quantity should be less than or equal to the coupon quantity in the store configuration.","Coupon quantity should be less than or equal to the coupon quantity in the store configuration."
173+
"Code Quantity Limit","Code Quantity Limit"
174+
"For better performance max value allowed is 250,000.","For better performance max value allowed is 250,000."

0 commit comments

Comments
 (0)