/** * Apply the query part to search for product where the completenesses * are missing. Apply only to the channel or product if provided. * * @param Builder $productsQb * @param ProductInterface $product * @param ChannelInterface $channel */ protected function applyFindMissingQuery(Builder $productsQb, ProductInterface $product = null, ChannelInterface $channel = null) { if (null !== $product) { $productsQb->field('_id')->equals($product->getId()); } else { $combinations = $this->getChannelLocaleCombinations($channel); if (!empty($combinations)) { foreach ($combinations as $combination) { $expr = new Expr(); $expr->field('normalizedData.completenesses.' . $combination)->exists(false); $productsQb->addOr($expr); } } } $productsQb->field('family')->notEqual(null); }