@param string $productMeasurementSalesUnitKey

@throws \Spryker\Zed\ProductMeasurementUnitDataImport\Business\Exception\EntityNotFoundException

@return int
964862
protected function getIdProductMeasurementSalesUnitByKey($productMeasurementSalesUnitKey): int
    {
        $spyProductMeasurementSalesUnitEntity = SpyProductMeasurementSalesUnitQuery::create()
            ->findOneByKey($productMeasurementSalesUnitKey);

        if (!$spyProductMeasurementSalesUnitEntity) {
            throw new EntityNotFoundException(
                sprintf('Product measurement sales unit with key "%s" was not found during import.', $productMeasurementSalesUnitKey)
            );
        }

        return $spyProductMeasurementSalesUnitEntity->getIdProductMeasurementSalesUnit();
    }
1328509
protected function getProductMeasurementBaseUnit($idProductAbstract): SpyProductMeasurementBaseUnit
    {
        $spyProductMeasurementBaseUnitEntity = SpyProductMeasurementBaseUnitQuery::create()
            ->findOneByFkProductAbstract($idProductAbstract);

        if (!$spyProductMeasurementBaseUnitEntity) {
            throw new EntityNotFoundException(
                sprintf('Product measurement base unit was not found for product abstract id "%d" during data import.', $idProductAbstract)
            );
        }

        return $spyProductMeasurementBaseUnitEntity;
    }
475135
protected function getIdCompanyRoleByKey(string $companyRoleKey): int
    {
        if (!isset($this->idCompanyRoleListCache[$companyRoleKey])) {
            $idCompanyRole = $this->getCompanyRoleQuery()
                ->filterByKey($companyRoleKey)
                ->select(SpyCompanyRoleTableMap::COL_ID_COMPANY_ROLE)
                ->findOne();

            if (!$idCompanyRole) {
                throw new EntityNotFoundException(sprintf('Could not find company role by key "%s"', $companyRoleKey));
            }

            $this->idCompanyRoleListCache[$companyRoleKey] = $idCompanyRole;
        }

        return $this->idCompanyRoleListCache[$companyRoleKey];
    }
759027
protected function resolveIdProductByConcreteSku(string $sku): int
    {
        if (!isset($this->idProductCache[$sku])) {
            $productEntity = SpyProductQuery::create()
                ->findOneBySku($sku);

            if (!$productEntity) {
                throw new EntityNotFoundException(sprintf('Concrete product by sku "%s" not found.', $sku));
            }

            $this->idProductCache[$sku] = $productEntity->getIdProduct();
        }

        return $this->idProductCache[$sku];
    }
1205326
protected function getIdCompanyByKey(string $companyKey): int
    {
        if (!isset($this->idCompanyListCache[$companyKey])) {
            $idCompany = $this->getCompanyQuery()
                ->filterByKey($companyKey)
                ->select(SpyCompanyTableMap::COL_ID_COMPANY)
                ->findOne();

            if (!$idCompany) {
                throw new EntityNotFoundException(sprintf('Could not find company by key "%s"', $companyKey));
            }

            $this->idCompanyListCache[$companyKey] = $idCompany;
        }

        return $this->idCompanyListCache[$companyKey];
    }
1255520
public function countProductStatsLine()
    {
        $em = $this->getEntityManager();
        $query = $em->createQuery(
            'SELECT count(s.visits) as visit, s.day as day FROM EcommerceBundle:ProductStats as s GROUP BY s.day ORDER BY s.day ASC '
        );

        $stats = $query->getResult();

        return $stats;
    }
381845
public function countProductVisited()
    {
        $em = $this->getEntityManager();
        $query = $em->createQuery(
            'SELECT COUNT( DISTINCT s.product ) FROM  EcommerceBundle:ProductStats AS s'
        );

        $total = $query->getSingleScalarResult();

        return $total;
    }
74891
protected function saveProductMeasurementUnit(DataSetInterface $dataSet): SpyProductMeasurementUnit
    {
        $productMeasurementUnitEntity = SpyProductMeasurementUnitQuery::create()
            ->filterByCode($dataSet[ProductMeasurementUnitDataSet::COLUMN_CODE])
            ->findOneOrCreate();

        $productMeasurementUnitEntity
            ->setName($dataSet[ProductMeasurementUnitDataSet::COLUMN_NAME])
            ->setDefaultPrecision($this->filterDefaultPrecision($dataSet[ProductMeasurementUnitDataSet::COLUMN_DEFAULT_PRECISION]))
            ->save();
        return $productMeasurementUnitEntity;
    }
1232678
public function countDealerFolderVersions(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
    {
        $partial = $this->collDealerFolderVersionsPartial && !$this->isNew();
        if (null === $this->collDealerFolderVersions || null !== $criteria || $partial) {
            if ($this->isNew() && null === $this->collDealerFolderVersions) {
                return 0;
            }

            if ($partial && !$criteria) {
                return count($this->getDealerFolderVersions());
            }

            $query = ChildDealerFolderVersionQuery::create(null, $criteria);
            if ($distinct) {
                $query->distinct();
            }

            return $query
                ->filterByDealerFolder($this)
                ->count($con);
        }

        return count($this->collDealerFolderVersions);
    }
597913
protected function addProductMeasurementSalesUnitCheckToHeap(string $productSku): void
    {
        if (isset(static::$productMeasurementSalesUnitHeap[$productSku])) {
            return;
        }

        if (static::$productMeasurementSalesUnitHeapSize >= static::HEAP_LIMIT) {
            $this->clearProductMeasurementSalesUnitHeap();
        }

        $productConcreteId = $this->getIdProductBySku($productSku);

        static::$productMeasurementSalesUnitHeapSize++;
        static::$productMeasurementSalesUnitHeap[$productSku] = $this->getProductMeasurementSalesUnitQuery()
            ->filterByFkProduct($productConcreteId)
            ->exists();
    }
503077
public function countDealerShedulesVersions(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
    {
        $partial = $this->collDealerShedulesVersionsPartial && !$this->isNew();
        if (null === $this->collDealerShedulesVersions || null !== $criteria || $partial) {
            if ($this->isNew() && null === $this->collDealerShedulesVersions) {
                return 0;
            }

            if ($partial && !$criteria) {
                return count($this->getDealerShedulesVersions());
            }

            $query = ChildDealerShedulesVersionQuery::create(null, $criteria);
            if ($distinct) {
                $query->distinct();
            }

            return $query
                ->filterByDealerShedules($this)
                ->count($con);
        }

        return count($this->collDealerShedulesVersions);
    }
756798
public static function resolve($key)
    {
        if ($key == 'B') return 0;
        $dict = static::$metric;
        if (preg_match(static::IEC_PATTERN, $key))
            $dict = static::$binary;
        if (array_key_exists($key, $dict)) return $dict[$key];
        throw new UnitNotFoundException(sprintf('Unit "%s" not found', $key));
    }
1087781
public function findOrderEntityForItemWithId($id, $returnMultipleResults = false)
    {
        try {
            return $this->orderRepository->findOrderForItemWithId($id, $returnMultipleResults);
        } catch (NoResultException $nre) {
            throw new EntityNotFoundException(static::$itemEntity, $id);
        }
    }
804836
public function showVariationsAction(Request $request = null)
    {
        $id = $request->get($this->admin->getIdParameter());

        if (!$product = $this->admin->getObject($id)) {
            throw new NotFoundHttpException('Product not found.');
        }

        return $this->render('SonataProductBundle:ProductAdmin:variations.html.twig', [
            'product' => $product,
        ]);
    }
925262
protected function saveProductMeasurementBaseUnit(DataSetInterface $dataSet): SpyProductMeasurementBaseUnit
    {
        $productMeasurementBaseUnitEntity = SpyProductMeasurementBaseUnitQuery::create()
            ->filterByFkProductAbstract($this->getIdProductAbstractBySku($dataSet[ProductMeasurementBaseUnitDataSet::COLUMN_ABSTRACT_SKU]))
            ->findOneOrCreate();

        $productMeasurementBaseUnitEntity
            ->setFkProductMeasurementUnit($this->getProductMeasurementUnitIdByCode($dataSet[ProductMeasurementBaseUnitDataSet::COLUMN_CODE]))
            ->save();

        return $productMeasurementBaseUnitEntity;
    }
224450
protected function getIdPermissionByKey(string $permissionKey): int
    {
        if (!isset($this->idPermissionListCache[$permissionKey])) {
            $idPermission = $this->getPermissionQuery()
                ->filterByKey($permissionKey)
                ->select(SpyPermissionTableMap::COL_ID_PERMISSION)
                ->findOne();

            if (!$idPermission) {
                throw new EntityNotFoundException(sprintf('Could not find permission by key "%s"', $permissionKey));
            }

            $this->idPermissionListCache[$permissionKey] = $idPermission;
        }

        return $this->idPermissionListCache[$permissionKey];
    }
498225
public function getNextRevisionNumberForEntity(EntityInterface $entity): int
    {
        $revision = 1;
        $last = $this->find()
            ->select('revision')
            ->where([
                'model' => $this->getEntityModel($entity),
                'foreign_key' => $entity->id
            ])
            ->order(['revision DESC'])
            ->hydrate(false)
            ->first();

        if (isset($last['revision'])) {
            $revision = $last['revision'] + 1;
        }

        return $revision;
    }