/** * {@inheritdoc} */ public function getDeletedLocaleIdsForChannel(ChannelInterface $channel) { $currentLocaleIds = array_map(function ($locale) { return $locale->getId(); }, $channel->getLocales()->toArray()); $sql = <<<SQL SELECT cl.locale_id FROM pim_catalog_channel_locale cl WHERE cl.channel_id = :channel_id AND cl.locale_id NOT IN (:current_locale_ids) SQL; $stmt = $this->getEntityManager()->getConnection()->executeQuery($sql, [':channel_id' => $channel->getId(), ':current_locale_ids' => $currentLocaleIds], [':current_locale_ids' => Connection::PARAM_INT_ARRAY]); $rows = $stmt->fetchAll(); $locales = array_map(function ($row) { return (int) $row['locale_id']; }, $rows); return $locales; }
/** * {@inheritdoc} */ public function buildByChannelAndCompleteness(ChannelInterface $channel) { $scope = $channel->getCode(); $qb = $this->buildByScope($scope); $rootAlias = current($qb->getRootAliases()); $expression = 'pCompleteness.product = ' . $rootAlias . ' AND ' . $qb->expr()->eq('pCompleteness.ratio', '100') . ' AND ' . $qb->expr()->eq('pCompleteness.channel', $channel->getId()); $rootEntity = current($qb->getRootEntities()); $completenessMapping = $this->_em->getClassMetadata($rootEntity)->getAssociationMapping('completenesses'); $completenessClass = $completenessMapping['targetEntity']; $qb->innerJoin($completenessClass, 'pCompleteness', 'WITH', $expression); $treeId = $channel->getCategory()->getId(); $expression = $qb->expr()->eq('pCategory.root', $treeId); $qb->innerJoin($rootAlias . '.categories', 'pCategory', 'WITH', $expression); return $qb; }
/** * {@inheritdoc} */ public function scheduleForChannelAndLocale(ChannelInterface $channel, LocaleInterface $locale) { $productQb = $this->documentManager->createQueryBuilder($this->productClass); $pullExpr = $productQb->expr()->addAnd($productQb->expr()->field('channel')->equals($channel->getId()))->addAnd($productQb->expr()->field('locale')->equals($locale->getId())); $productQb->update()->multiple(true)->field(sprintf('normalizedData.completenesses.%s-%s', $channel->getCode(), $locale->getCode()))->unsetField()->field('completenesses')->pull($pullExpr)->getQuery()->execute(); }
/** * {@inheritdoc} */ public function scheduleForChannelAndLocale(ChannelInterface $channel, LocaleInterface $locale) { $sql = <<<SQL DELETE c FROM pim_catalog_completeness c WHERE c.channel_id = :channel_id AND c.locale_id = :locale_id SQL; $sql = $this->applyTableNames($sql); $stmt = $this->connection->prepare($sql); $stmt->bindValue('channel_id', $channel->getId()); $stmt->bindValue('locale_id', $locale->getId()); $stmt->execute(); }
/** * {@inheritdoc} */ public function getDeletedLocalesForChannel(ChannelInterface $channel) { $currentLocaleIds = array_map(function (LocaleInterface $locale) { return $locale->getId(); }, $channel->getLocales()->toArray()); return $this->createQueryBuilder('l')->innerJoin('l.channels', 'lc')->andWhere('lc.id = :channel_id')->andWhere('l.id NOT IN (:current_locale_ids)')->setParameter(':channel_id', $channel->getId())->setParameter(':current_locale_ids', implode(',', $currentLocaleIds))->getQuery()->getResult(); }