Skip to content

Magento2.4 enterprise cloud programatically create gift card

I have a phtml file in our magento2.4.4 enterprise cloud which I call via url and want to when the page is loaded programmatically generate a gift card.

My phtml file which is embedded in a cms page has the below code:

  <?php
      $gift_card = Mage::getModel('enterprise_giftcardaccount/giftcardaccount');
      $gift_card
            ->setCode('2i2j2j-24k1ii1')
            ->setStatus($gift_card::STATUS_ENABLED)
            ->setDateExpires('2025-04-15')
            ->setWebsiteId(1)
            ->setState($gift_card::STATE_AVAILABLE)
            ->setIsRedeemable($gift_card::REDEEMABLE)
            ->setBalance(25);

      $gift_card->save();

?>

My issue is when I load the page I get a error that says An error has happened during application run.

Wondering if anyone has a suggestion on where the error may be in the below code?

thank you