Model/Api/DiscountCodeValidation.php
public function loadGiftCardData($code)
    {
        $result = null;

        /** @var \Magento\GiftCardAccount\Model\ResourceModel\Giftcardaccount\Collection $giftCardAccount */
        $giftCardAccountResource = $this->moduleGiftCardAccount->getInstance();

        if ($giftCardAccountResource) {
            $this->logHelper->addInfoLog('### GiftCard ###');
            $this->logHelper->addInfoLog('# Code: ' . $code);

            /** @var \Magento\GiftCardAccount\Model\ResourceModel\Giftcardaccount\Collection $giftCardsCollection */
            $giftCardsCollection = $giftCardAccountResource
                ->addFieldToFilter('code', ['eq' => $code]);

            /** @var \Magento\GiftCardAccount\Model\Giftcardaccount $giftCard */
            $giftCard = $giftCardsCollection->getFirstItem();

            $result = (!$giftCard->isEmpty() && $giftCard->isValid()) ? $giftCard : null;
        }

        $this->logHelper->addInfoLog('# loadGiftCertData Result is empty: '. ((!$result) ? 'yes' : 'no'));

        return $result;
    }
public function loadGiftCardData($code)
    {
        $result = null;

        /** @var \Magento\GiftCardAccount\Model\ResourceModel\Giftcardaccount\Collection $giftCardAccount */
        $giftCardAccountResource = $this->moduleGiftCardAccount->getInstance();

        if ($giftCardAccountResource) {
            $this->logHelper->addInfoLog('### GiftCard ###');
            $this->logHelper->addInfoLog('# Code: ' . $code);

            /** @var \Magento\GiftCardAccount\Model\ResourceModel\Giftcardaccount\Collection $giftCardsCollection */
            $giftCardsCollection = $giftCardAccountResource
                ->addFieldToFilter('code', ['eq' => $code]);

            /** @var \Magento\GiftCardAccount\Model\Giftcardaccount $giftCard */
            $giftCard = $giftCardsCollection->getFirstItem();

            $result = (!$giftCard->isEmpty() && $giftCard->isValid()) ? $giftCard : null;
        }

        $this->logHelper->addInfoLog('# loadGiftCertData Result is empty: '. ((!$result) ? 'yes' : 'no'));

        return $result;
    }
public function loadGiftCardData ( $ code ) { $ result = null ; /** @var \Magento\GiftCardAccount\Model\ResourceModel\Giftcardaccount\Collection $giftCardAccount */ $ giftCardAccountResource = $ this -> moduleGiftCardAccount -> getInstance ( ) ; if ( $ giftCardAccountResource ) { $ this -> logHelper -> addInfoLog ( '### GiftCard ###' ) ; $ this -> logHelper -> addInfoLog ( '# Code: ' . $ code ) ; /** @var \Magento\GiftCardAccount\Model\ResourceModel\Giftcardaccount\Collection $giftCardsCollection */ $ giftCardsCollection = $ giftCardAccountResource -> addFieldToFilter ( 'code' , [ 'eq' => $ code ] ) ; /** @var \Magento\GiftCardAccount\Model\Giftcardaccount $giftCard */ $ giftCard = $ giftCardsCollection -> getFirstItem ( ) ; $ result = ( ! $ giftCard -> isEmpty ( ) && $ giftCard -> isValid ( ) ) ? $ giftCard : null ; } $ this -> logHelper -> addInfoLog ( '# loadGiftCertData Result is empty: ' . ( ( ! $ result ) ? 'yes' : 'no' ) ) ; return $ result ; }
Load the gift card data by code

@param $code
@return \Magento\GiftCardAccount\Model\Giftcardaccount|null
Load the gift card data by code