本文整理汇总了PHP中Pim\Bundle\CatalogBundle\Repository\ProductRepositoryInterface类的典型用法代码示例。如果您正苦于以下问题:PHP ProductRepositoryInterface类的具体用法?PHP ProductRepositoryInterface怎么用?PHP ProductRepositoryInterface使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ProductRepositoryInterface类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
function it_checks_value_existence(ProductRepositoryInterface $productRepository, ProductValueInterface $value)
{
$productRepository->valueExists($value)->willReturn(true);
$this->valueExists($value)->shouldReturn(true);
$productRepository->valueExists($value)->willReturn(false);
$this->valueExists($value)->shouldReturn(false);
}
示例2: apply
/**
* {@inheritdoc}
*/
public function apply(DatasourceInterface $datasource, $field, $direction)
{
$attribute = $this->attributeRepository->findOneByCode($field);
$qb = $datasource->getQueryBuilder();
$pqb = $this->productRepository->getProductQueryBuilder($qb);
$pqb->addAttributeSorter($attribute, $direction);
}
示例3: updateProductAssociationExport
/**
* Update product association export date for the given product.
*
* @param JobInstance $jobInstance
* @param string $identifier
*/
public function updateProductAssociationExport(JobInstance $jobInstance, $identifier)
{
$product = $this->productRepository->findByReference((string) $identifier);
if ($product) {
$this->updateExport($product, $jobInstance, $this->tableNameBuilder->getTableName('pim_magento_connector.entity.delta_product_association_export.class'));
}
}
示例4: listProductsAction
/**
* Display the products of a group
*
* @param string $identifier
*
* @return JsonResponse
*
* @AclAncestor("pim_enrich_product_index")
*/
public function listProductsAction($identifier)
{
$group = $this->groupRepository->findOneBy(['code' => $identifier]);
if (!$group) {
throw new NotFoundHttpException(sprintf('Group with code "%s" not found', $identifier));
}
return new JsonResponse($this->normalizer->normalize(['products' => $this->productRepository->getProductsByGroup($group, self::MAX_PRODUCTS), 'productCount' => $this->productRepository->getProductCountByGroup($group)], 'internal_api'));
}
示例5: findProductOr404
/**
* Find a product by its id or return a 404 response
*
* @param string $id the product id
*
* @throws NotFoundHttpException
*
* @return ProductInterface
*/
protected function findProductOr404($id)
{
$product = $this->productRepository->findOneByWithValues($id);
if (!$product) {
throw new NotFoundHttpException(sprintf('Product with id %s could not be found.', (string) $id));
}
return $product;
}
示例6: completenessAction
/**
* Displays completeness for a product
*
* @param int $id
*
* @return Response
*/
public function completenessAction($id)
{
$product = $this->productRepository->getFullProduct($id);
$channels = $this->channelManager->getFullChannels();
$locales = $this->userContext->getUserLocales();
$completenesses = $this->completenessManager->getProductCompleteness($product, $channels, $locales, $this->userContext->getCurrentLocale()->getCode());
return $this->templating->renderResponse('PimEnrichBundle:Completeness:_completeness.html.twig', ['product' => $product, 'channels' => $channels, 'locales' => $locales, 'completenesses' => $completenesses]);
}
示例7: findProductOr404
/**
* Find a product by its id or return a 404 response
*
* @param int $id the product id
*
* @throws NotFoundHttpException
*
* @return ProductInterface
*/
protected function findProductOr404($id)
{
$product = $this->productRepository->findOneById($id);
if (!$product) {
throw new NotFoundHttpException(sprintf('Product with id %s could not be found.', $id));
}
$this->productBuilder->addMissingAssociations($product);
return $product;
}
示例8: getAction
/**
* Get completeness for a product
*
* @param int $id
*
* @return JSONResponse
*/
public function getAction($id)
{
$product = $this->productRepository->getFullProduct($id);
$this->completenessManager->generateMissingForProduct($product);
$channels = $this->channelRepository->getFullChannels();
$locales = $this->userContext->getUserLocales();
$filteredLocales = $this->collectionFilter->filterCollection($locales, 'pim.internal_api.locale.view');
$completenesses = $this->completenessManager->getProductCompleteness($product, $channels, $filteredLocales, $this->userContext->getCurrentLocale()->getCode());
return new JsonResponse($this->completenessNormalizer->normalize($completenesses, 'internal_api'));
}
示例9: apply
/**
* {@inheritdoc}
*/
public function apply(DatasourceInterface $datasource, $field, $direction)
{
$qb = $datasource->getQueryBuilder();
$groupId = $this->requestParams->get('currentGroup', null);
if (!$groupId) {
throw new \LogicException('The current product group must be configured');
}
$field = 'in_group_' . $groupId;
$pqb = $this->repository->getProductQueryBuilder($qb);
$pqb->addFieldSorter($field, $direction);
}
示例10: prepareParameters
/**
* @return array
*/
protected function prepareParameters()
{
$queryParameters = parent::prepareParameters();
$variantGroupId = $queryParameters['currentGroup'];
if (null !== $variantGroupId) {
$productIds = $this->productRepository->getEligibleProductIdsForVariantGroup($variantGroupId);
if (count($productIds) === 0) {
$productIds = [0];
}
} else {
$productIds = [0];
}
$queryParameters['productIds'] = $productIds;
return $queryParameters;
}
示例11: addCurrentProduct
/**
* Inject current product in the datagrid configuration
*/
protected function addCurrentProduct()
{
$path = $this->getSourcePath(self::CURRENT_PRODUCT_KEY);
$id = $this->requestParams->get('product', null);
$product = null !== $id ? $this->productRepository->findOneByWithValues($id) : null;
$this->configuration->offsetSetByPath($path, $product);
}
示例12: findEntity
/**
* {@inheritdoc}
*/
protected function findEntity($class, array $data)
{
if (!$this->identifierAttribute) {
throw new MissingIdentifierException();
}
return $this->productRepository->findOneByIdentifier($data[$this->identifierAttribute->getCode()]);
}
示例13: read
/**
* {@inheritdoc}
*/
public function read()
{
$this->documentManager->clear();
if (!$this->executed) {
$this->executed = true;
if (!is_object($this->channel)) {
$this->channel = $this->channelManager->getChannelByCode($this->channel);
}
if ($this->missingCompleteness) {
$this->completenessManager->generateMissingForChannel($this->channel);
}
$this->query = $this->repository->buildByChannelAndCompleteness($this->channel)->getQuery();
$this->products = $this->getQuery()->execute();
// MongoDB Cursor are not positioned on first element (whereas ArrayIterator is)
// as long as getNext() hasn't be called
$this->products->getNext();
}
$result = $this->products->current();
if ($result) {
$this->metricConverter->convert($result, $this->channel);
$this->stepExecution->incrementSummaryInfo('read');
$this->products->next();
}
return $result;
}
示例14: getMatchingProductsForVariantGroup
/**
* Get matching products for variant group
*
* @param GroupInterface $variantGroup the variant group
*
* @return ProductInterface[]
*/
protected function getMatchingProductsForVariantGroup(GroupInterface $variantGroup)
{
if (!$variantGroup->getId()) {
return [];
}
return $this->repository->findAllForVariantGroup($variantGroup);
}
示例15: quickExport
/**
* {@inheritdoc}
*/
protected function quickExport()
{
$productIds = $this->massActionDispatcher->dispatch($this->request);
$fieldsList = $this->fieldsBuilder->getFieldsList($productIds);
$attributeIds = $this->fieldsBuilder->getAttributeIds();
$context = $this->getContext() + ['fields' => $fieldsList];
// batch output to avoid memory leak
$offset = 0;
$batchSize = 100;
while ($productsList = array_slice($productIds, $offset, $batchSize)) {
$results = $this->productRepository->getFullProducts($productsList, $attributeIds);
echo $this->serializer->serialize($results, $this->getFormat(), $context);
$offset += $batchSize;
flush();
}
}