@param \Magento\Quote\Model\Quote $quote
@param int $websiteId
@param int $storeId

@return bool
331498
private function updateDataFieldAndCreateAc($quote, $websiteId, $storeId)
    {
        $this->cartInsight->send($quote, $storeId);

        $quoteId = $quote->getId();
        $items = $quote->getAllItems();
        $email = $quote->getCustomerEmail();
        $itemIds = $this->getQuoteItemIds($items);
        $abandonedModel = $this->abandonedFactory->create()
            ->loadByQuoteId($quoteId);
        $contact = $this->helper->getContact($email, $websiteId);
        if (!$contact) {
            return false;
        }

        if ($contact->status === self::STATUS_PENDING) {
            $this->createAbandonedCart($abandonedModel, $quote, $itemIds, self::STATUS_PENDING);
            return false;
        }
        if ($this->abandonedCartAlreadyExists($abandonedModel) &&
            $this->shouldNotSendACAgain($abandonedModel, $quote) &&
            $this->isNotAConfirmedContact($abandonedModel)
        ) {
            if ($this->shouldDeleteAbandonedCart($quote)) {
                $this->deleteAbandonedCart($abandonedModel);
            }
            return false;
        } else {
            if ($mostExpensiveItem = $this->getMostExpensiveItems($items)) {
                $this->helper->updateAbandonedProductName(
                    $mostExpensiveItem->getName(),
                    $email,
                    $websiteId
                );
            }
            $this->createAbandonedCart($abandonedModel, $quote, $itemIds, self::STATUS_SENT);
            return true;
        }
    }
1044108
public function isValidSiteId($siteId, $checkActive = false)
    {
        if (empty($siteId) || !is_numeric($siteId)) {
            return false;
        }

        if ($checkActive && in_array($siteId, $this->activeSiteIdCache)) {
            return true;
        }

        $queryBuilder = $this->_em->createQueryBuilder();
        $queryBuilder->select('site.siteId')
            ->from(\Rcm\Entity\Site::class, 'site')
            ->where('site.siteId = :siteId')
            ->setParameter('siteId', $siteId);

        if ($checkActive) {
            $queryBuilder->andWhere('site.status = :status');
            $queryBuilder->setParameter('status', \Rcm\Entity\Site::STATUS_ACTIVE);
        }

        $result = $queryBuilder->getQuery()->getScalarResult();

        if (!empty($result)) {
            if ($checkActive) {
                $this->activeSiteIdCache[] = $siteId;
            }

            return true;
        }

        return false;
    }
1296809
public function isStoreEnabled($storeId)
    {
        return $this->scopeConfig->isSetFlag(
            \Dotdigitalgroup\Email\Helper\Config::XML_PATH_CONNECTOR_API_ENABLED,
            \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
            $storeId
        );
    }
69321
private function saveEvent($websiteId, $storeId, $type, $entityId, $data)
    {
        $data = $this->json->serialize($data);

        /** @var EventModel $eventModel */
        $eventModel = $this->eventFactory->create()
            ->setEntityId($entityId)
            ->setWebsiteId($websiteId)
            ->setStoreId($storeId)
            ->setEventType($type)
            ->setEventData($data);

        $this->eventRepository->save($eventModel);
    }
704362
public function loadInventoryData($storeId, $productIds)
    {
        $websiteId = $this->getWebsiteId($storeId);
        $stockId   = $this->getStockId($websiteId);
        $tableName = $this->stockIndexTableProvider->execute($stockId);

        $select = $this->getConnection()->select()
            ->from(['product' => $this->getTable('catalog_product_entity')], [])
            ->join(
                ['stock_index' => $tableName],
                'product.sku = stock_index.' . IndexStructure::SKU,
                [
                    'product_id'    => 'product.entity_id',
                    'stock_status'  => 'stock_index.' . IndexStructure::IS_SALABLE,
                    'qty'           => 'stock_index.' . IndexStructure::QUANTITY,
                ]
            )
            ->where('product.entity_id IN (?)', $productIds)
            ->group('product.entity_id');

        return $this->getConnection()->fetchAll($select);
    }
1097353
public function getPaymentFeeAmount(Mage_Sales_Model_Quote $quote, $store = null)
    {
        $paymentMethod = $quote->getPayment()->getMethod();
        if ($paymentMethod == 'adyen_openinvoice') {
            return Mage::getStoreConfig('payment/adyen_openinvoice/fee');
        } elseif ($paymentMethod == 'adyen_ideal') {
            return Mage::getStoreConfig('payment/adyen_ideal/fee');
        } elseif (substr($paymentMethod, 0, 10) == 'adyen_hpp_') {
            return $this->getHppPaymentMethodFee($paymentMethod);
        }

        return 0;
    }
194104
protected function isMapped($optionId, $storeId)
    {
        return (isset($this->optionValueStoreMapping[$optionId]) && in_array($storeId, $this->optionValueStoreMapping[$optionId]));
    }
131703
public function getAttributesRawData($storeId, array $entityIds, $tableName, array $attributeIds)
    {
        $select = $this->connection->select();

        // The field modelizing the link between entity table and attribute values table. Either row_id or entity_id.
        $linkField = $this->getEntityMetaData($this->getEntityTypeId())->getLinkField();

        // The legacy entity_id field.
        $entityIdField = $this->getEntityMetaData($this->getEntityTypeId())->getIdentifierField();

        $joinStoreValuesConditionClauses = [
            "t_default.$linkField = t_store.$linkField",
            't_default.attribute_id = t_store.attribute_id',
            't_store.store_id= ?',
        ];

        $joinStoreValuesCondition = $this->connection->quoteInto(
            implode(' AND ', $joinStoreValuesConditionClauses),
            $storeId
        );

        $select->from(['entity' => $this->getEntityMetaData($this->getEntityTypeId())->getEntityTable()], [$entityIdField])
            ->joinInner(
                ['t_default' => $tableName],
                new \Zend_Db_Expr("entity.{$linkField} = t_default.{$linkField}"),
                ['attribute_id']
            )
            ->joinLeft(['t_store' => $tableName], $joinStoreValuesCondition, [])
            ->where('t_default.store_id=?', 0)
            ->where('t_default.attribute_id IN (?)', $attributeIds)
            ->where("entity.{$entityIdField} IN (?)", $entityIds)
            ->columns(['value' => new \Zend_Db_Expr('COALESCE(t_store.value, t_default.value)')]);

        return $this->connection->fetchAll($select);
    }
310431
private function loadPvForQuote($quoteId)
    {
        if (!isset($this->cachePvQuote[$quoteId])) {
            $found = $this->daoPvQuote->getById((int)$quoteId);
            $this->cachePvQuote[$quoteId] = $found;
        }
        return $this->cachePvQuote[$quoteId];
    }
433837
public function findOneByEmailAndWebsiteId($email, $websiteId)
    {

        // initialize the params
        $params = array(
            MemberNames::EMAIL      => $email,
            MemberNames::WEBSITE_ID => $websiteId
        );

        // if not, try to load the customer with the passed email and website ID
        $this->customerByEmailAndWebsiteIdStmt->execute($params);
        return $this->customerByEmailAndWebsiteIdStmt->fetch(\PDO::FETCH_ASSOC);
    }
356325
private function updateSearchContext($storeId, $queryText)
    {
        $this->searchContext->setStoreId($storeId);
        $query = $this->queryFactory->create();
        $query->setStoreId($storeId);
        $query->loadByQueryText($queryText);

        if ($query->getId()) {
            $this->searchContext->setCurrentSearchQuery($query);
        }
    }
353245
public function store($customerId, $websiteId, $storeId, $type = null)
    {
        if (!$this->isEnabledForWebsite($websiteId)) {
            return false;
        }

        if (!$type) {
            $type = self::DEFAULT_TYPE;
        }

        /** @var Customer $customer */
        $customer = $this->customerFactory->create()->load($customerId);

        $customerData = $customer->toArray();
        $customerData['id'] = $customerData['entity_id'];

        if ($customer->getDefaultBillingAddress()) {
            $customerData['billing_address'] = $customer->getDefaultBillingAddress()->toArray();
        }
        if ($customer->getDefaultShippingAddress()) {
            $customerData['shipping_address'] = $customer->getDefaultShippingAddress()->toArray();
        }

        $subscription = $this->subscriber->loadByCustomerId($customerId);
        $customerData['accepts_marketing'] = $subscription->getStatus();

        $this->saveEvent($websiteId, $storeId, $type, $customer->getId(), $customerData);

        return true;
    }
44392
public function loadByQuoteId($quoteId, $storeId)
    {
        $item = $this->campaignCollection->create()
            ->loadByQuoteId($quoteId, $storeId);

        if ($item) {
            return $item;
        } else {
            return $this->setQuoteId($quoteId)
                ->setStoreId($storeId);
        }
    }
455582
async function nextQuote(store) {
  await store.update(state => {
    state.quoteId = state.quoteId + 1
    if (state.quoteId >= MAX_QUOTE_ID) {
      state.quoteId = 1
    }
  })
}
637445
private function isValidStoreId($storeId)
    {
        $stores = $this->storeManager->getStores(true);
        if (array_key_exists($storeId, $stores)) {
            return true;
        }

        // @todo hs: build up array of storeCodes, to prevent wasting time looping
        if (is_numeric($storeId)) {
            // Dont bother checking store codes on numeric input
            return false;
        }
        /** @var Store $store */
        foreach ($stores as $store) {
            if ($store->getCode() == $storeId) {
                return true;
            }
        }

        return false;
    }
865139
public function setEntity(MageQuote $quote)
    {
        $id    = $this->sgBase->getExternalCustomerId();
        $email = $this->sgBase->getMail();

        try {
            $customer = $id ? $this->customerHelper->getById($id) : $this->customerHelper->getByEmail($email);
        } catch (NoSuchEntityException $e) {
            $customer = new DataObject();
            $this->log->debug('Could not load customer by id or mail.');
        }
        $quote->setCustomerEmail($email)
            ->setRemoteIp($this->sgBase->getCustomerIp());
        if ($this->sgBase->isGuest()) {
            $quote->setCustomerIsGuest(true);
        } elseif ($customer->getId()) {
            $this->session->setCustomerId($customer->getId())->setCustomerGroupId($customer->getGroupId());

            $quote->setCustomer($customer)
                ->setCustomerIsGuest(false);
        } else {
            throw new \ShopgateLibraryException(
                \ShopgateLibraryException::UNKNOWN_ERROR_CODE,
                __('Customer with external id "%1" or email "%2" does not exist', $id, $email)->render()
            );
        }
    }
588914
private function getStoreData($productId, $storeId, $attributeCode)
    {
        if (array_key_exists($productId, $this->attributeData)
            && array_key_exists($storeId, $this->attributeData[$productId])
            && array_key_exists($attributeCode, $this->attributeData[$productId][$storeId])
        ) {
            return $this->attributeData[$productId][$storeId][$attributeCode];
        }

        return null;
    }