当前位置: 首页>>代码示例>>PHP>>正文


PHP GroupInterface::getProductTemplate方法代码示例

本文整理汇总了PHP中Pim\Component\Catalog\Model\GroupInterface::getProductTemplate方法的典型用法代码示例。如果您正苦于以下问题:PHP GroupInterface::getProductTemplate方法的具体用法?PHP GroupInterface::getProductTemplate怎么用?PHP GroupInterface::getProductTemplate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Pim\Component\Catalog\Model\GroupInterface的用法示例。


在下文中一共展示了GroupInterface::getProductTemplate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: normalizeVariantGroupValues

 /**
  * {@inheritdoc}
  */
 protected function normalizeVariantGroupValues(GroupInterface $group, $format, array $context)
 {
     if (!$group->getType()->isVariant() || null === $group->getProductTemplate()) {
         return [];
     }
     $valuesData = $group->getProductTemplate()->getValuesData();
     $values = $this->valuesDenormalizer->denormalize($valuesData, 'ProductValue[]', 'json');
     $normalizedValues = [];
     foreach ($values as $value) {
         $normalizedValues = array_replace($normalizedValues, $this->serializer->normalize($value, $format, ['entity' => 'product'] + $context));
     }
     ksort($normalizedValues);
     return $normalizedValues;
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:17,代码来源:GroupNormalizer.php

示例2: ProductValue

 function it_updates_a_variant_group($attributeRepository, $groupTypeRepository, $productBuilder, GroupInterface $variantGroup, AttributeInterface $attribute, GroupTypeInterface $type, GroupTranslation $translatable, ProductInterface $product, ProductTemplateInterface $productTemplate)
 {
     $groupTypeRepository->findOneByIdentifier('VARIANT')->willReturn($type);
     $attributeRepository->findOneByIdentifier('main_color')->willReturn($attribute);
     $attributeRepository->findOneByIdentifier('secondary_color')->willReturn($attribute);
     $variantGroup->getTranslation()->willReturn($translatable);
     $translatable->setLabel('T-shirt super beau')->shouldBeCalled();
     $variantGroup->setCode('mycode')->shouldBeCalled();
     $variantGroup->setLocale('fr_FR')->shouldBeCalled();
     $variantGroup->setType($type)->shouldBeCalled();
     $variantGroup->getId()->willReturn(null);
     $variantGroup->addAxisAttribute(Argument::any())->shouldBeCalled();
     $productTemplate->getValuesData()->willReturn([]);
     $productTemplate->setValues(Argument::any())->shouldBeCalled();
     $productTemplate->setValuesData(['main_color' => [['locale' => null, 'scope' => null, 'data' => 'white']]])->shouldBeCalled();
     $variantGroup->getProductTemplate()->willReturn($productTemplate);
     $variantGroup->setProductTemplate($productTemplate)->shouldBeCalled();
     $productValue = new ProductValue();
     $identifierValue = new ProductValue();
     $productBuilder->createProduct()->willReturn($product);
     $product->getValues()->willReturn(new ArrayCollection([$productValue, $identifierValue]));
     $product->getIdentifier()->willReturn($identifierValue);
     $values = ['code' => 'mycode', 'axis' => ['main_color', 'secondary_color'], 'type' => 'VARIANT', 'labels' => ['fr_FR' => 'T-shirt super beau'], 'values' => ['main_color' => [['locale' => null, 'scope' => null, 'data' => 'white']]]];
     $this->update($variantGroup, $values, []);
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:25,代码来源:VariantGroupUpdaterSpec.php

示例3: normalizeVariantGroupValues

 /**
  * Normalize the variant group values
  *
  * @param GroupInterface $variantGroup
  *
  * @return array
  */
 protected function normalizeVariantGroupValues(GroupInterface $variantGroup)
 {
     if (null === ($template = $variantGroup->getProductTemplate())) {
         return [];
     }
     return $template->getValuesData();
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:14,代码来源:VariantGroupNormalizer.php

示例4:

 function it_handles_media_values_of_variant_group_product_templates($templateMediaManager, $eventDispatcher, GroupInterface $group, GroupType $type, ProductTemplateInterface $template)
 {
     $group->getType()->willReturn($type);
     $group->getCode()->willReturn('my_code');
     $type->isVariant()->willReturn(true);
     $group->getProductTemplate()->willReturn($template);
     $templateMediaManager->handleProductTemplateMedia($template)->shouldBeCalled();
     $eventDispatcher->dispatch(StorageEvents::PRE_SAVE, Argument::cetera())->shouldBeCalled();
     $eventDispatcher->dispatch(StorageEvents::POST_SAVE, Argument::cetera())->shouldBeCalled();
     $this->save($group);
 }
开发者ID:alexisfroger,项目名称:pim-community-dev,代码行数:11,代码来源:GroupSaverSpec.php

示例5: FileNotFoundException

 function it_throws_an_exception_if_media_of_variant_group_is_not_found($normalizer, $denormalizer, ArrayCollection $productValuesCollection, ArrayCollection $mediaCollection, ProductMediaInterface $media, GroupInterface $variantGroup, ProductTemplateInterface $productTemplate, ProductValueInterface $productValue)
 {
     $variantGroup->getProductTemplate()->willReturn($productTemplate);
     $variantGroup->getCode()->willReturn('my_variant_group');
     $productTemplate->getValuesData()->willReturn([$productValue]);
     $denormalizer->denormalize([$productValue], 'ProductValue[]', 'json')->willReturn($productValuesCollection);
     $productValuesCollection->filter(Argument::cetera())->willReturn($mediaCollection);
     $mediaCollection->toArray()->willReturn([$media]);
     $normalizer->normalize([$media], 'csv', ['field_name' => 'media', 'prepare_copy' => true, 'identifier' => 'my_variant_group'])->willThrow(new FileNotFoundException('upload/path/img.jpg'));
     $this->shouldThrow(new InvalidItemException('The file "upload/path/img.jpg" does not exist', ['item' => 'my_variant_group', 'uploadDirectory' => 'upload/path/']))->duringProcess($variantGroup);
 }
开发者ID:alexisfroger,项目名称:pim-community-dev,代码行数:11,代码来源:VariantGroupProcessorSpec.php

示例6:

 function it_returns_non_eligible_attributes($attributeRepository, GroupInterface $group, ProductTemplateInterface $template, AttributeInterface $length, AttributeInterface $name, AttributeInterface $color, AttributeInterface $identifier, Collection $collection)
 {
     $group->getProductTemplate()->willReturn($template);
     $group->getAxisAttributes()->willReturn($collection);
     $collection->toArray()->willReturn([$length]);
     $template->getValuesData()->willReturn(['name' => 'foo', 'color' => 'bar']);
     $attributeRepository->findOneByIdentifier('name')->willReturn($name);
     $attributeRepository->findOneByIdentifier('color')->willReturn($color);
     $attributeRepository->findBy(['unique' => true])->willReturn([$name, $identifier]);
     $attributes = [$length, $name, $color, $identifier];
     $this->getNonEligibleAttributes($group)->shouldReturn($attributes);
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:12,代码来源:VariantGroupAttributesResolverSpec.php

示例7: fetchMedia

 /**
  * Fetch medias in local filesystem
  *
  * @param GroupInterface $variantGroup
  * @param string         $directory
  */
 protected function fetchMedia(GroupInterface $variantGroup, $directory)
 {
     if (null === ($productTemplate = $variantGroup->getProductTemplate())) {
         return;
     }
     $identifier = $variantGroup->getCode();
     $this->variantGroupUpdater->update($variantGroup, ['values' => $productTemplate->getValuesData()]);
     $this->mediaFetcher->fetchAll($productTemplate->getValues(), $directory, $identifier);
     foreach ($this->mediaFetcher->getErrors() as $error) {
         $this->stepExecution->addWarning($error['message'], [], new DataInvalidItem($error['media']));
     }
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:18,代码来源:VariantGroupProcessor.php

示例8: validateProductTemplateValues

 /**
  * Validate variant group product template values
  *
  * @param GroupInterface $variantGroup
  * @param Constraint     $constraint
  */
 protected function validateProductTemplateValues(GroupInterface $variantGroup, Constraint $constraint)
 {
     $template = $variantGroup->getProductTemplate();
     $valuesData = $template->getValuesData();
     $forbiddenAttrCodes = $this->attributeRepository->findUniqueAttributeCodes();
     foreach ($variantGroup->getAxisAttributes() as $axisAttribute) {
         $forbiddenAttrCodes[] = $axisAttribute->getCode();
     }
     $invalidAttrCodes = array_intersect($forbiddenAttrCodes, array_keys($valuesData));
     if (count($invalidAttrCodes) > 0) {
         $this->context->buildViolation($constraint->message, ['%group%' => $variantGroup->getCode(), '%attributes%' => $this->formatValues($invalidAttrCodes)])->addViolation();
     }
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:19,代码来源:VariantGroupValuesValidator.php

示例9:

 function it_does_not_copy_values_to_products_when_template_is_empty(GroupInterface $variantGroup, ProductTemplateInterface $productTemplate, Collection $productCollection, ProductInterface $productOne, ProductInterface $productTwo, $productTplApplier, $stepExecution)
 {
     $variantGroup->getId()->willReturn(42);
     $stepExecution->incrementSummaryInfo('process')->shouldBeCalled();
     $variantGroup->getProductTemplate()->willReturn($productTemplate);
     $productTemplate->getValuesData()->willReturn([]);
     $variantGroup->getProducts()->willReturn($productCollection);
     $productCollection->isEmpty()->willReturn(false);
     $productCollection->toArray()->willReturn([$productOne, $productTwo]);
     $productCollection->count()->willReturn(2);
     $productTplApplier->apply($productTemplate, [$productOne, $productTwo])->shouldNotBeCalled();
     $this->write([$variantGroup]);
 }
开发者ID:alexisfroger,项目名称:pim-community-dev,代码行数:13,代码来源:VariantGroupWriterSpec.php

示例10: ArrayCollection

 function it_handles_media_values_of_variant_group_product_templates($optionsResolver, $templateMediaManager, $eventDispatcher, GroupInterface $group, GroupType $type, ProductTemplateInterface $template)
 {
     $optionsResolver->resolveSaveOptions(Argument::any())->willReturn(['flush' => true, 'copy_values_to_products' => false]);
     $group->getProducts()->willReturn(new ArrayCollection([]));
     $group->getType()->willReturn($type);
     $group->getCode()->willReturn('my_code');
     $group->getId()->willReturn(null);
     $group->getProductTemplate()->willReturn($template);
     $type->isVariant()->willReturn(true);
     $templateMediaManager->handleProductTemplateMedia($template)->shouldBeCalled();
     $eventDispatcher->dispatch(StorageEvents::PRE_SAVE, Argument::cetera())->shouldBeCalled();
     $eventDispatcher->dispatch(StorageEvents::POST_SAVE, Argument::cetera())->shouldBeCalled();
     $this->save($group);
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:14,代码来源:GroupSaverSpec.php

示例11: getNonEligibleAttributes

 /**
  * Get non eligible attributes to a product template
  *
  * @param GroupInterface $variantGroup
  *
  * @return AttributeInterface[]
  */
 public function getNonEligibleAttributes(GroupInterface $variantGroup)
 {
     $attributes = $variantGroup->getAxisAttributes()->toArray();
     $template = $variantGroup->getProductTemplate();
     if (null !== $template) {
         foreach (array_keys($template->getValuesData()) as $attributeCode) {
             $attributes[] = $this->attributeRepository->findOneByIdentifier($attributeCode);
         }
     }
     $uniqueAttributes = $this->attributeRepository->findBy(['unique' => true]);
     foreach ($uniqueAttributes as $attribute) {
         if (!in_array($attribute, $attributes)) {
             $attributes[] = $attribute;
         }
     }
     return $attributes;
 }
开发者ID:alexisfroger,项目名称:pim-community-dev,代码行数:24,代码来源:VariantGroupAttributesResolver.php

示例12:

 function it_adds_a_violation_if_variant_group_template_contains_a_unique_attribute(GroupInterface $variantGroup, GroupType $type, ProductTemplateInterface $template, VariantGroupValues $constraint, $attributeRepository, $context, ConstraintViolationBuilderInterface $violation)
 {
     $variantGroup->getType()->willReturn($type);
     $variantGroup->getCode()->willReturn('tshirt');
     $type->isVariant()->willReturn(true);
     $variantGroup->getProductTemplate()->willReturn($template);
     $variantGroup->getAxisAttributes()->willReturn([]);
     $attributeRepository->findUniqueAttributeCodes()->willReturn(['sku', 'barcode']);
     $template->getValuesData()->willReturn(['sku' => 'SKU-001']);
     $violationData = ['%group%' => 'tshirt', '%attributes%' => '"sku"'];
     $context->buildViolation($constraint->message, $violationData)->shouldBeCalled()->willReturn($violation);
     $this->validate($variantGroup, $constraint);
     $template->getValuesData()->willReturn(['sku' => 'SKU-001', 'barcode' => 01122334455]);
     $violationData = ['%group%' => 'tshirt', '%attributes%' => '"sku", "barcode"'];
     $context->buildViolation($constraint->message, $violationData)->shouldBeCalled()->willReturn($violation);
     $this->validate($variantGroup, $constraint);
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:17,代码来源:VariantGroupValuesValidatorSpec.php

示例13:

 function it_normalizes_a_variant_group_with_its_values($transNormalizer, $valuesDenormalizer, $valuesNormalizer, GroupInterface $group, GroupTypeInterface $groupType, AttributeInterface $attr, ProductTemplateInterface $productTemplate)
 {
     $groupType->getCode()->willReturn('VARIANT');
     $groupType->isVariant()->willReturn(true);
     $group->getCode()->willReturn('laser_sabers');
     $valuesData = ['name' => 'Light saber model', 'size' => '120'];
     $context = ['with_variant_group_values' => true];
     $format = 'csv';
     $productTemplate->getValuesData()->willReturn($valuesData);
     $valuesDenormalizer->denormalize($valuesData, Argument::any(), Argument::any())->willReturn('denormalized_values');
     $valuesNormalizer->normalize('denormalized_values', Argument::any(), Argument::any())->willReturn('normalized_values');
     $group->getProductTemplate()->willReturn($productTemplate);
     $group->getType()->willReturn($groupType);
     $attr->getCode()->willReturn('light_color');
     $group->getAxisAttributes()->willReturn([$attr]);
     $transNormalizer->normalize($group, $format, $context)->willReturn([]);
     $this->normalize($group, $format, $context)->shouldReturn(['code' => 'laser_sabers', 'type' => 'VARIANT', 'axis' => ['light_color'], 'values' => 'normalized_values']);
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:18,代码来源:GroupNormalizerSpec.php

示例14: copyValuesToProducts

 /**
  * Copy variant group values to products
  *
  * @param GroupInterface $variantGroup
  */
 protected function copyValuesToProducts(GroupInterface $variantGroup)
 {
     $template = $variantGroup->getProductTemplate();
     $products = $variantGroup->getProducts();
     if ($template && count($template->getValuesData()) > 0 && count($products) > 0) {
         $skippedMessages = $this->productTplApplier->apply($template, $products->toArray());
         $nbSkipped = count($skippedMessages);
         $nbUpdated = count($products) - $nbSkipped;
         $this->incrementUpdatedProductsCount($nbUpdated);
         if ($nbSkipped > 0) {
             $this->incrementSkippedProductsCount($nbSkipped, $skippedMessages);
         }
     }
 }
开发者ID:alexisfroger,项目名称:pim-community-dev,代码行数:19,代码来源:VariantGroupWriter.php

示例15: prepareVariantGroupMedia

 /**
  * Prepares media files present in the product template of the variant group for export.
  * Returns an array of files to be copied from 'filePath' to 'exportPath'.
  *
  * @param GroupInterface $group
  *
  * @throws InvalidItemException If a media file is not found
  *
  * @return array
  */
 protected function prepareVariantGroupMedia(GroupInterface $group)
 {
     $mediaValues = $this->getProductTemplateMediaValues($group->getProductTemplate());
     if (count($mediaValues) < 1) {
         return [];
     }
     try {
         return $this->normalizer->normalize($mediaValues, $this->format, ['field_name' => 'media', 'prepare_copy' => true, 'identifier' => $group->getCode()]);
     } catch (FileNotFoundException $e) {
         throw new InvalidItemException($e->getMessage(), ['item' => $group->getCode(), 'uploadDirectory' => $this->uploadDirectory]);
     }
 }
开发者ID:alexisfroger,项目名称:pim-community-dev,代码行数:22,代码来源:VariantGroupProcessor.php


注:本文中的Pim\Component\Catalog\Model\GroupInterface::getProductTemplate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。