How to create Gift Card Account programmatically, as I need to get coupon code using API.

I am looking if it is possible to trigger built in observer programmatically in Model class e.g

<event name="magento_giftcardaccount_create">

the function is:

public function execute(\Magento\Framework\Event\Observer $observer)
    $data = $observer->getEvent()->getRequest();
    $code = $observer->getEvent()->getCode();
    $order = $data->getOrder() ?: ($data->getOrderItem()->getOrder() ?: null);

    $model = $this->giftCAFactory->create()->setStatus(


    return $this;

How can it be achieved, or it should be done by some other way ?

Your Answer

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

Browse other questions tagged or ask your own question.