Model/Automation/UpdateFields/Update.php
public function updateAbandonedCartDatafields($email, $websiteId, $quoteId, $parentStoreName)
    {
        $website = $this->storeManager->getWebsite($websiteId);

        // Load the origin quote
        $quoteModel = $this->magentoQuoteFactory->create()
            ->loadByIdWithoutStore($quoteId);
        $items = $quoteModel->getAllItems();

        // Nominate the most expensive item in the cart as the 'abandoned product'
        $nominatedAbandonedCartItem = $this->ddgQuoteFactory->create()
            ->getMostExpensiveItems($items);

        if ($lastQuoteId = $website->getConfig(
            \Dotdigitalgroup\Email\Helper\Config::XML_PATH_CONNECTOR_MAPPING_LAST_QUOTE_ID
        )
        ) {
            $data[] = [
                'Key' => $lastQuoteId,
                'Value' => $quoteId,
            ];
        }
        if ($abandonedProductName = $website->getConfig(
            \Dotdigitalgroup\Email\Helper\Config::XML_PATH_CONNECTOR_ABANDONED_PRODUCT_NAME
        )
        ) {
            $data[] = [
                'Key' => $abandonedProductName,
                'Value' => $nominatedAbandonedCartItem->getName(),
            ];
        }
        if ($storeName = $website->getConfig(
            \Dotdigitalgroup\Email\Helper\Config::XML_PATH_CONNECTOR_CUSTOMER_STORE_NAME
        )
        ) {
            $data[] = [
                'Key' => $storeName,
                'Value' => $parentStoreName,
            ];
        }
        if ($websiteName = $website->getConfig(
            \Dotdigitalgroup\Email\Helper\Config::XML_PATH_CONNECTOR_CUSTOMER_WEBSITE_NAME
        )
        ) {
            $data[] = [
                'Key' => $websiteName,
                'Value' => $website->getName(),
            ];
        }
        if (!empty($data)) {
            $client = $this->helper->getWebsiteApiClient($website);
            $client->updateContactDatafieldsByEmail(
                $email,
                $data
            );
        }
    }
public function updateAbandonedCartDatafields($email, $websiteId, $quoteId, $parentStoreName)
    {
        $website = $this->storeManager->getWebsite($websiteId);

        // Load the origin quote
        $quoteModel = $this->magentoQuoteFactory->create()
            ->loadByIdWithoutStore($quoteId);
        $items = $quoteModel->getAllItems();

        // Nominate the most expensive item in the cart as the 'abandoned product'
        $nominatedAbandonedCartItem = $this->ddgQuoteFactory->create()
            ->getMostExpensiveItems($items);

        if ($lastQuoteId = $website->getConfig(
            \Dotdigitalgroup\Email\Helper\Config::XML_PATH_CONNECTOR_MAPPING_LAST_QUOTE_ID
        )
        ) {
            $data[] = [
                'Key' => $lastQuoteId,
                'Value' => $quoteId,
            ];
        }
        if ($abandonedProductName = $website->getConfig(
            \Dotdigitalgroup\Email\Helper\Config::XML_PATH_CONNECTOR_ABANDONED_PRODUCT_NAME
        )
        ) {
            $data[] = [
                'Key' => $abandonedProductName,
                'Value' => $nominatedAbandonedCartItem->getName(),
            ];
        }
        if ($storeName = $website->getConfig(
            \Dotdigitalgroup\Email\Helper\Config::XML_PATH_CONNECTOR_CUSTOMER_STORE_NAME
        )
        ) {
            $data[] = [
                'Key' => $storeName,
                'Value' => $parentStoreName,
            ];
        }
        if ($websiteName = $website->getConfig(
            \Dotdigitalgroup\Email\Helper\Config::XML_PATH_CONNECTOR_CUSTOMER_WEBSITE_NAME
        )
        ) {
            $data[] = [
                'Key' => $websiteName,
                'Value' => $website->getName(),
            ];
        }
        if (!empty($data)) {
            $client = $this->helper->getWebsiteApiClient($website);
            $client->updateContactDatafieldsByEmail(
                $email,
                $data
            );
        }
    }
public function updateAbandonedCartDatafields ( $ email , $ websiteId , $ quoteId , $ parentStoreName ) { $ website = $ this -> storeManager -> getWebsite ( $ websiteId ) ; // Load the origin quote
 $ quoteModel = $ this -> magentoQuoteFactory -> create ( ) -> loadByIdWithoutStore ( $ quoteId ) ; $ items = $ quoteModel -> getAllItems ( ) ; // Nominate the most expensive item in the cart as the 'abandoned product'
 $ nominatedAbandonedCartItem = $ this -> ddgQuoteFactory -> create ( ) -> getMostExpensiveItems ( $ items ) ; if ( $ lastQuoteId = $ website -> getConfig ( \ Dotdigitalgroup \ Email \ Helper \ Config :: XML_PATH_CONNECTOR_MAPPING_LAST_QUOTE_ID ) ) { $ data [ ] = [ 'Key' => $ lastQuoteId , 'Value' => $ quoteId , ] ; } if ( $ abandonedProductName = $ website -> getConfig ( \ Dotdigitalgroup \ Email \ Helper \ Config :: XML_PATH_CONNECTOR_ABANDONED_PRODUCT_NAME ) ) { $ data [ ] = [ 'Key' => $ abandonedProductName , 'Value' => $ nominatedAbandonedCartItem -> getName ( ) , ] ; } if ( $ storeName = $ website -> getConfig ( \ Dotdigitalgroup \ Email \ Helper \ Config :: XML_PATH_CONNECTOR_CUSTOMER_STORE_NAME ) ) { $ data [ ] = [ 'Key' => $ storeName , 'Value' => $ parentStoreName , ] ; } if ( $ websiteName = $ website -> getConfig ( \ Dotdigitalgroup \ Email \ Helper \ Config :: XML_PATH_CONNECTOR_CUSTOMER_WEBSITE_NAME ) ) { $ data [ ] = [ 'Key' => $ websiteName , 'Value' => $ website -> getName ( ) , ] ; } if ( ! empty ( $ data ) ) { $ client = $ this -> helper -> getWebsiteApiClient ( $ website ) ; $ client -> updateContactDatafieldsByEmail ( $ email , $ data ) ; } }
Update abandoned cart data fields.

@param string $email
@param int $websiteId
@param int $quoteId
@param string $parentStoreName

@return void
@throws \Magento\Framework\Exception\LocalizedException
Update abandoned cart data fields .