I am trying to create auto generated coupon codes for a specific rule programmatically. But facing problems continuously. Can you please help me out?

1 Answer 1

    use Magento\Framework\App\Bootstrap;
    require __DIR__ . '/../app/bootstrap.php';

    $bootstrap = Bootstrap::create(BP, $_SERVER);

    $obj = $bootstrap->getObjectManager();

    $state = $obj->get('Magento\Framework\App\State');
    $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); 

    $rule_id = 11 ;
    $isactive = $rule->getIsActive(); 


        $expirationDate = strtotime("+30 day");
        $code ="FEOMCEE12";
        $coupon = $objectManager->create('Magento\SalesRule\Model\Coupon');        


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.