Set time window for abandoned cart program enrolments

@param int $storeId

@return array
@throws \Exception
489573
public function getAbandonedCartProgramEnrolmentWindow($storeId)
    {
        $fromTime = $this->dateTimeFactory->create(
            [
                'time' => 'now',
                'timezone' => new \DateTimezone('UTC')
            ]
        );

        $minutes = (int) $this->helper->getScopeConfig()->getValue(
            \Dotdigitalgroup\Email\Helper\Config::XML_PATH_LOSTBASKET_ENROL_TO_PROGRAM_INTERVAL,
            \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
            $storeId
        );

        $interval = $this->dateIntervalFactory->create(
            ['interval_spec' => sprintf('PT%sM', $minutes)]
        );

        $fromTime->sub($interval);
        $toTime = clone $fromTime;
        $fromTime->sub($this->dateIntervalFactory->create(['interval_spec' => 'PT5M']));

        return [
            'from' => $fromTime->format('Y-m-d H:i:s'),
            'to' => $toTime->format('Y-m-d H:i:s'),
            'date' => true,
        ];
    }
704298
public function getLostBasketCustomerInterval($num, $storeId)
    {
        return $this->scopeConfig->getValue(
            constant('self::XML_PATH_LOSTBASKET_CUSTOMER_INTERVAL_' . $num),
            \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
            $storeId
        );
    }
524588
public function getTotalsChangeSelectors($storeId = null)
    {
        return $this->getScopeConfig()->getValue(
            self::XML_PATH_TOTALS_CHANGE_SELECTORS,
            ScopeInterface::SCOPE_STORE,
            $storeId
        );
    }
574803
protected function updateStore($store_id)
    {
        if (!$this->isError() && !$this->store->update($store_id, $this->getSubmitted())) {
            $this->errorAndExit($this->text('Unexpected result'));
        }
    }
421454
public function getOnShippingDetailsComplete($storeId = null)
    {
        return $this->getScopeConfig()->getValue(
            self::XML_PATH_TRACK_SHIPPING_DETAILS_COMPLETE,
            ScopeInterface::SCOPE_STORE,
            $storeId
        );
    }
487031
private function getIPWhitelistConfig($storeId = null)
    {
        return $this->getScopeConfig()->getValue(
            self::XML_PATH_IP_WHITELIST,
            ScopeInterface::SCOPE_STORE,
            $storeId
        );
    }
1224629
private function processConfirmedGuestAbandonedCart($storeId, $guestCampaignId)
    {
        $ac1QuoteIdsWithConfirmedContacts = $this->abandonedCollectionFactory->create()
            ->getCollectionByConfirmedStatus($storeId, true)
            ->getColumnValues('quote_id');

        $quoteCollectionFromIds = $this->orderCollection->create()
            ->getStoreQuotesFromQuoteIds($ac1QuoteIdsWithConfirmedContacts, $storeId);
        return $this->createGuestFirstAbandonedCart(
            $quoteCollectionFromIds,
            $storeId,
            $guestCampaignId
        );
    }
1340139
public function getOnCheckoutStart($storeId = null)
    {
        return $this->getScopeConfig()->getValue(
            self::XML_PATH_TRACK_CHECKOUT_START,
            ScopeInterface::SCOPE_STORE,
            $storeId
        );
    }
1138831
public function loadCategoryData($storeId, $productIds)
    {
        $select       = $this->getCategoryProductSelect($productIds, $storeId);
        $categoryData = $this->getConnection()->fetchAll($select);

        $categoryIds = [];

        foreach ($categoryData as $categoryDataRow) {
            $categoryIds[] = $categoryDataRow['category_id'];
        }

        $storeCategoryName = $this->loadCategoryNames(array_unique($categoryIds), $storeId);

        foreach ($categoryData as &$categoryDataRow) {
            $categoryDataRow['name'] = '';
            if (isset($storeCategoryName[(int) $categoryDataRow['category_id']])) {
                $categoryDataRow['name'] = $storeCategoryName[(int) $categoryDataRow['category_id']];
            }
        }

        return $categoryData;
    }
1341425
public function getOnSuccess($storeId = null)
    {
        return $this->getScopeConfig()->getValue(
            self::XML_PATH_TRACK_SUCCESS,
            ScopeInterface::SCOPE_STORE,
            $storeId
        );
    }
499358
public function getExpansions($storeId)
    {
        $connection = $this->getConnection();
        $select     = $this->getBaseSelect($storeId, ThesaurusInterface::TYPE_EXPANSION);

        $select->join(
            ['expanded_terms' => $this->getTable(ThesaurusInterface::REFERENCE_TABLE_NAME)],
            'expanded_terms.term_id = terms.term_id AND expanded_terms.thesaurus_id = terms.thesaurus_id',
            []
        );

        $select->columns(['terms' => new \Zend_Db_Expr('CONCAT(expanded_terms.term, " => " ,GROUP_CONCAT(terms.term))')]);

        return $connection->fetchCol($select);
    }
779001
public function getSessionData($storeId, $sessionIds)
    {
        $data = [];
        $searchRequest  = $this->getSearchRequest($storeId, $sessionIds);
        $searchResponse = $this->searchEngine->search($searchRequest);

        foreach ($searchResponse->getAggregations()->getBucket('session_id')->getValues() as $sessionValue) {
            $sessionData = $this->processSessionData($sessionValue);
            $sessionData['store_id'] = $storeId;
            unset($sessionData['count']);

            $data[] = array_filter($sessionData);
        }

        return $data;
    }
1132567
public function editStore($store_id = null)
    {
        $this->setStore($store_id);
        $this->seTitleEditStore();
        $this->setBreadcrumbEditStore();

        $this->setData('store', $this->data_store);
        $this->setData('themes', $this->getListThemeStore());
        $this->setData('is_default', $this->isDefaultStore());
        $this->setData('can_delete', $this->canDeleteStore());
        $this->setData('countries', $this->getCountriesStore());
        $this->setData('collections', $this->getListCollectionStore());
        $this->setData('languages', $this->language->getList(array('enabled' => true)));

        $this->submitEditStore();
        $this->setDataEditStore();

        $this->setJsEditStore();
        $this->outputEditStore();
    }
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;
    }
1264432
public function getActiveCarriers($storeId = null)
    {
        return $this->carrierConfig->getActiveCarriers($this->storeManager->getStore($storeId));
    }
1149534
private function getBaseSelectGlobal($productIds, $storeId)
    {
        $select = $this->getConnection()->select()
            ->from(['cpi' => $this->getTable($this->getCategoryProductIndexTable($storeId))], [])
            ->joinLeft(
                ['p' => $this->getTable(ProductPositionResourceModel::TABLE_NAME)],
                'p.product_id = cpi.product_id AND p.category_id = cpi.category_id AND p.store_id = 0',
                []
            );

        $this->joinStorePosition($select, $storeId, 0);

        $select->where('cpi.store_id = ?', (int) $storeId)
            ->where('cpi.product_id IN(?)', $productIds)
            ->columns([
                'category_id'    => 'cpi.category_id',
                'product_id'     => 'cpi.product_id',
                'is_parent'      => 'cpi.is_parent',
                'is_virtual'     => new \Zend_Db_Expr('"false"'),
                'position'       => 'p.position',
                'is_blacklisted' => 'p.is_blacklisted',
            ]);

        return $select;
    }
297333
protected function getSendAfterIntervalForGuest($storeId, $num)
    {
        $timeInterval = $this->getLostBasketSendAfterForGuest($num, $storeId);

        //for the  first cart which use the minutes
        if ($num == 1) {
            $interval = $this->dateIntervalFactory->create(
                ['interval_spec' => sprintf('PT%sM', $timeInterval)]
            );
        } else {
            $interval = $this->dateIntervalFactory->create(
                ['interval_spec' => sprintf('PT%sH', $timeInterval)]
            );
        }

        return $interval;
    }