Register review campaign.

@param \Magento\Sales\Model\ResourceModel\Order\Collection $collection
@param int $websiteId

@return null
347617
public function registerCampaign($collection, $websiteId)
    {
        //review campaign id
        $campaignId = $this->helper->getCampaign($websiteId);

        if ($campaignId) {
            foreach ($collection as $order) {
                $this->helper->log(
                    '-- Order Review: ' . $order->getIncrementId()
                    . ' Campaign Id: ' . $campaignId
                );

                try {
                    $emailCampaign = $this->campaignFactory->create()
                        ->setEmail($order->getCustomerEmail())
                        ->setStoreId($order->getStoreId())
                        ->setCampaignId($campaignId)
                        ->setEventName('Order Review')
                        ->setCreatedAt($this->dateTime->formatDate(true))
                        ->setOrderIncrementId($order->getIncrementId())
                        ->setQuoteId($order->getQuoteId());

                    if ($order->getCustomerId()) {
                        $emailCampaign->setCustomerId($order->getCustomerId());
                    }
                    $this->campaignResource->saveItem($emailCampaign);
                } catch (\Exception $e) {
                    $this->helper->debug((string)$e, []);
                }
            }
        }
    }
469725
protected function isUserGranted($permission, Website $website, $collection = null)
    {
        if (null === $collection) {
            $collection = new ResourceCollection([$website->getResourceNode()]);
        }
        $checkPermission = false;
        if ($this->get('security.authorization_checker')->isGranted($permission, $collection)) {
            $checkPermission = true;
        }

        return $checkPermission;
    }
820182
public function loadByCustomerEmail($email, $websiteId)
    {
        $customer = $this->getCollection()
            ->loadByCustomerEmail($email, $websiteId);

        if ($customer) {
            return $customer;
        } else {
            return $this->setEmail($email)
                ->setWebsiteId($websiteId);
        }
    }
448213
public function deploySite($serverId, $siteId, $wait = true)
    {
        $this->post("servers/$serverId/sites/$siteId/deployment/deploy");

        if ($wait) {
            $this->retry($this->getTimeout(), function () use ($serverId, $siteId) {
                return is_null($this->site($serverId, $siteId)->deploymentStatus);
            });
        }
    }
1180573
public function decorate(Collection $collection)
    {
        if ($this->storeManager->isSingleStoreMode()) {
            return;
        }

        $this->addLinkedWebsiteIds($collection);
        $this->ensureWebsiteLinkedSet($collection);
    }
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;
        }
    }
114976
public function viewAction($collectionId)
    {
        $this->denyAccessUnlessGranted('ez:infocollector:read');

        $collection = $this->service->getCollection(new Query(['collectionId' => $collectionId]));

        return $this->render("NetgenInformationCollectionBundle:admin:view.html.twig", [
            'collection' => $collection,
            'content' => $collection->content,
        ]);
    }
193000
public function viewAction($collectionId, $slug)
    {
        $collection = $this->get('sonata.classification.manager.collection')->findOneBy(['id' => $collectionId]);

        if (!$collection) {
            throw new NotFoundHttpException(sprintf('Unable to find the collection with id=%d', $collectionId));
        }

        return $this->render('SonataProductBundle:Collection:view.html.twig', [
           'collection' => $collection,
        ]);
    }
323137
public function isSubscriberSyncEnabled($websiteId = 0)
    {
        return $this->scopeConfig->getValue(
            \Dotdigitalgroup\Email\Helper\Config::XML_PATH_CONNECTOR_SYNC_SUBSCRIBER_ENABLED,
            \Magento\Store\Model\ScopeInterface::SCOPE_WEBSITE,
            $websiteId
        );
    }
392512
public static function getDbRef($collection, $documentId)
  {
    static::checkConnexion();
    $ref = self::$db->createDBRef($collection, $documentId);
    return $ref;
  }
1283861
public function registerCollection(array $collection)
    {
        foreach ($collection as $name => $handler) {
            $this->register($name, $handler);
        }

        return $this;
    }
1083077
public function ddl(Collection $collection)
    {
        if (!empty($this->options['autoddl'])) {
            $sql = $this->dialect->grammarDDL($collection, $this->options['autoddl']);

            $this->execute($sql);
        }
    }
1266831
public function getSalesDataForSubscribersWithOrderStatusesAndBrand($emails, $websiteId)
    {
        $orderStatuses = $this->config->getWebsiteConfig(
            Config::XML_PATH_CONNECTOR_SYNC_DATA_FIELDS_STATUS,
            $websiteId
        );
        $orderStatuses = explode(',', $orderStatuses);

        $orderCollection = $this->orderCollectionFactory->create()
            ->addFieldToSelect(['customer_email'])
            ->addExpressionFieldToSelect('total_spend', 'SUM({{grand_total}})', 'grand_total')
            ->addExpressionFieldToSelect('number_of_orders', 'COUNT({{*}})', '*')
            ->addExpressionFieldToSelect('average_order_value', 'AVG({{grand_total}})', 'grand_total')
            ->addFieldToFilter('customer_email', ['in' => $emails]);

        $columns = $this->buildCollectionColumns();
        $orderCollection->getSelect()
            ->columns($columns)
            ->group('customer_email');

        if (! empty($orderStatuses)) {
            $orderCollection->getSelect()->where('status in (?)', $orderStatuses);
        }

        $orderArray = [];
        foreach ($orderCollection as $item) {
            $orderArray[$item->getCustomerEmail()] = $item->toArray(
                [
                    'total_spend',
                    'number_of_orders',
                    'average_order_value',
                    'last_order_date',
                    'first_order_id',
                    'last_order_id',
                    'last_increment_id',
                    'product_id_for_first_brand',
                    'product_id_for_last_brand',
                    'week_day',
                    'month_day',
                    'product_id_for_most_sold_product'
                ]
            );
        }

        return $orderArray;
    }
731741
public function countWithFilter(PaginateFinderConfiguration $configuration, array $siteIds)
    {
        $qa = $this->createQueryWithFilter($configuration, $siteIds);

        return $this->countDocumentAggregateQuery($qa);
    }
920680
public function deleteRegistrationsOnCollection(\collection $collection)
    {
        $qb = $this->repository->createQueryBuilder('d');
        $qb->delete('Phraseanet:Registration', 'd');
        $qb->where($qb->expr()->eq('d.baseId', ':base'));
        $qb->setParameter(':base', $collection->get_base_id());
        $qb->getQuery()->execute();
    }
725685
private function getConsentText($websiteId)
    {
        $consentText = $this->configHelper->getConsentSubscriberText($websiteId);
        $customerConsentText = $this->configHelper->getConsentCustomerText($websiteId);
        //customer checkout and registration if consent text not empty
        if ($this->isLinkMatchCustomerRegistrationOrCheckout($this->getConsentUrl()) && strlen($customerConsentText)) {
            $consentText = $customerConsentText;
        }
        return $consentText;
    }
21354
public function sync($collection)
    {
        foreach ($collection as $item) {
            $result = true;
            $websiteId = $item->getWebsiteId();
            if ($this->helper->isEnabled($websiteId)) {
                $this->client = $this->helper->getWebsiteApiClient($websiteId);
                $importData = $this->serializer->unserialize($item->getImportData());

                if ($this->client) {
                    $key = $importData[0];
                    $collectionName = $item->getImportType();
                    $this->client->deleteContactsTransactionalData($key, $collectionName);
                    $this->_handleSingleItemAfterSync($item, $result);
                }
            }
        }
    }