本文整理汇总了PHP中Pim\Component\Catalog\Model\ProductInterface::getIdentifier方法的典型用法代码示例。如果您正苦于以下问题:PHP ProductInterface::getIdentifier方法的具体用法?PHP ProductInterface::getIdentifier怎么用?PHP ProductInterface::getIdentifier使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pim\Component\Catalog\Model\ProductInterface
的用法示例。
在下文中一共展示了ProductInterface::getIdentifier方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: use
function it_normalizes_the_properties_of_the_product($filter, $serializer, ProductInterface $product, AttributeInterface $attribute, ProductValueInterface $value, FamilyInterface $family, ArrayCollection $values, \ArrayIterator $iterator, ProductValueInterface $identifier)
{
$values->getIterator()->willReturn($iterator);
$family->getCode()->willReturn('my_family');
$product->getFamily()->willReturn($family);
$product->getGroupCodes()->willReturn([]);
$product->getVariantGroup()->willReturn(null);
$product->getCategoryCodes()->willReturn([]);
$product->isEnabled()->willReturn(true);
$value->getAttribute()->willReturn($attribute);
$attribute->getCode()->willReturn('name');
$product->getIdentifier()->willReturn($identifier);
$identifier->getData()->willReturn('my_code');
$product->getValues()->willReturn($values);
$filter->filterCollection($values, 'pim.transform.product_value.structured', Argument::type('array'))->shouldBeCalled()->willReturn($values);
$iterator->rewind()->willReturn(null);
$valueCount = 1;
$iterator->valid()->will(function () use(&$valueCount) {
return $valueCount-- > 0;
});
$iterator->current()->willReturn($value);
$iterator->next()->willReturn(null);
$context = ['filter_types' => ['pim.transform.product_value.structured']];
$serializer->normalize($value, 'standard', $context)->willReturn(['locale' => null, 'scope' => null, 'value' => 'foo']);
$created = new \DateTime('2010-06-23');
$product->getCreated()->willReturn($created);
$serializer->normalize($created, 'standard')->willReturn('2010-06-23T00:00:00+01:00');
$updated = new \DateTime('2010-06-23 23:00:00');
$product->getUpdated()->willReturn($updated);
$serializer->normalize($updated, 'standard')->willReturn('2010-06-23T23:00:00+01:00');
$this->normalize($product, 'standard', $context)->shouldReturn(['identifier' => 'my_code', 'family' => 'my_family', 'groups' => [], 'variant_group' => null, 'categories' => [], 'enabled' => true, 'values' => ['name' => [['locale' => null, 'scope' => null, 'value' => 'foo']]], 'created' => '2010-06-23T00:00:00+01:00', 'updated' => '2010-06-23T23:00:00+01:00']);
}
示例2:
function it_does_not_validate_products_with_multiple_variant_group($context, $onlyOneVariantGroup, ProductInterface $mug, CustomGroupInterface $mugVariantGroup, CustomGroupInterface $otherGroup, GroupTypeInterface $variantType, ConstraintViolationBuilderInterface $violation)
{
$mug->getGroups()->willReturn([$mugVariantGroup, $otherGroup]);
$mugVariantGroup->getType()->willReturn($variantType);
$mugVariantGroup->__toString()->willReturn('mug');
$otherGroup->getType()->willReturn($variantType);
$otherGroup->__toString()->willReturn('other');
$variantType->isVariant()->willReturn(true);
$mug->getIdentifier()->willReturn('mug');
$context->buildViolation($onlyOneVariantGroup->message, ['%groups%' => 'mug, other', '%product%' => 'mug'])->shouldBeCalled()->willReturn($violation);
$this->validate($mug, $onlyOneVariantGroup);
}
示例3: normalize
/**
* {@inheritdoc}
*
* @param ProductInterface $object
*/
public function normalize($object, $format = null, array $context = [])
{
$context = $this->resolveContext($context);
$results = $this->serializer->normalize($object->getIdentifier(), $format, $context);
$results[self::FIELD_FAMILY] = $this->normalizeFamily($object->getFamily());
$results[self::FIELD_GROUPS] = $this->normalizeGroups($object->getGroupCodes());
$results[self::FIELD_CATEGORY] = $this->normalizeCategories($object->getCategoryCodes());
$results = array_merge($results, $this->normalizeAssociations($object->getAssociations()));
$results = array_replace($results, $this->normalizeValues($object, $format, $context));
$results[self::FIELD_ENABLED] = (int) $object->isEnabled();
return $results;
}
示例4:
function it_adds_a_violation_when_validates_a_product_with_missing_value_for_an_axe_of_its_variant_group($context, ProductInterface $product, GroupInterface $tShirtVariantGroup, AttributeInterface $sizeAttribute, AttributeInterface $colorAttribute, ProductValueInterface $sizeValue, ProductValueInterface $identifierValue, HasVariantAxes $constraint, ConstraintViolationBuilderInterface $violation)
{
$tShirtVariantGroup->getCode()->willReturn('tshirt');
$tShirtVariantGroup->getAxisAttributes()->willReturn([$sizeAttribute, $colorAttribute]);
$sizeAttribute->getCode()->willReturn('size');
$colorAttribute->getCode()->willReturn('color');
$product->getIdentifier()->willReturn($identifierValue);
$product->getVariantGroup()->willReturn($tShirtVariantGroup);
$product->getValue('size')->willReturn($sizeValue);
$product->getValue('color')->willReturn(null);
$sizeValue->getData()->willReturn('XL');
$context->buildViolation('The product "%product%" is in the variant group "%variant%" but it misses the following axes: %axes%.', ['%product%' => $identifierValue, '%variant%' => 'tshirt', '%axes%' => 'color'])->shouldBeCalled()->willReturn($violation);
$this->validate($product, $constraint);
}
示例5: ConstraintViolationList
function it_does_not_set_values_when_attribute_is_not_editable($validator, $productUpdater, $productDetacher, $productRepository, ProductInterface $product, ProductValueInterface $productValue, StepExecution $stepExecution, JobExecution $jobExecution, JobParameters $jobParameters)
{
$this->setStepExecution($stepExecution);
$product->getIdentifier()->shouldBeCalled()->willReturn($productValue);
$product->getId()->willReturn(10);
$productValue->getData()->shouldBeCalled();
$stepExecution->getJobParameters()->willReturn($jobParameters);
$jobParameters->get('filters')->willReturn([]);
$jobParameters->get('actions')->willReturn(['normalized_values' => json_encode(['categories' => [['scope' => null, 'locale' => null, 'data' => ['office', 'bedroom']]]]), 'ui_locale' => 'en_US', 'attribute_locale' => 'en_US', 'attribute_channel' => null]);
$stepExecution->getJobExecution()->willReturn($jobExecution);
$stepExecution->incrementSummaryInfo('skipped_products')->shouldBeCalled();
$stepExecution->addWarning('pim_enrich.mass_edit_action.edit-common-attributes.message.no_valid_attribute', [], Argument::any())->shouldBeCalled();
$productDetacher->detach($product)->shouldBeCalled();
$violations = new ConstraintViolationList([]);
$validator->validate($product)->willReturn($violations);
$productRepository->hasAttributeInFamily(10, 'categories')->shouldBeCalled()->willReturn(true);
$productRepository->hasAttributeInVariantGroup(10, 'categories')->shouldBeCalled()->willReturn(true);
$productUpdater->update($product, Argument::any())->shouldNotBeCalled();
$this->process($product)->shouldReturn(null);
}
示例6:
function it_returns_flat_data_with_media($channelManager, $serializer, Filesystem $filesystem, ChannelInterface $channel, ProductInterface $product, FileInfoInterface $media1, FileInfoInterface $media2, ProductValueInterface $value1, ProductValueInterface $value2, AttributeInterface $attribute, ProductValueInterface $identifierValue, AttributeInterface $identifierAttribute)
{
$media1->getKey()->willReturn('key/to/media1.jpg');
$media2->getKey()->willReturn('key/to/media2.jpg');
$value1->getAttribute()->willReturn($attribute);
$value1->getMedia()->willReturn($media1);
$value2->getAttribute()->willReturn($attribute);
$value2->getMedia()->willReturn($media2);
$attribute->getAttributeType()->willReturn('pim_catalog_image');
$product->getValues()->willReturn([$value1, $value2, $identifierValue]);
$identifierValue->getAttribute()->willReturn($identifierAttribute);
$identifierAttribute->getAttributeType()->willReturn('pim_catalog_identifier');
$product->getIdentifier()->willReturn($identifierValue);
$identifierValue->getData()->willReturn('data');
$filesystem->has('key/to/media1.jpg')->willReturn(true);
$filesystem->has('key/to/media2.jpg')->willReturn(true);
$serializer->normalize($media1, 'flat', ['field_name' => 'media', 'prepare_copy' => true, 'value' => $value1])->willReturn(['normalized_media1']);
$serializer->normalize($media2, 'flat', ['field_name' => 'media', 'prepare_copy' => true, 'value' => $value2])->willReturn(['normalized_media2']);
$serializer->normalize($product, 'flat', ['scopeCode' => 'foobar', 'localeCodes' => '', 'decimal_separator' => '.', 'date_format' => 'yyyy-MM-dd'])->willReturn(['normalized_product']);
$channelManager->getChannelByCode('foobar')->willReturn($channel);
$this->setChannel('foobar');
$this->process($product)->shouldReturn(['media' => [['normalized_media1'], ['normalized_media2']], 'product' => ['normalized_product']]);
}
示例7: serializeProduct
/**
* Serialize a single product
*
* @param ProductInterface $product
* @param string[] $channels
* @param string[] $locales
*
* @return array
*/
protected function serializeProduct(ProductInterface $product, $channels, $locales)
{
$url = $this->generateUrl('oro_api_get_product', ['identifier' => $product->getIdentifier()->getData()], true);
$handler = $this->container->get('pim_webservice.handler.rest.product');
$data = $handler->get($product, $channels, $locales, $url);
return $data;
}
示例8: getReference
/**
* {@inheritdoc}
*/
public function getReference()
{
return $this->owner ? $this->owner->getIdentifier() . '.' . $this->associationType->getCode() : null;
}
示例9: FileNotFoundException
function it_throws_an_exception_if_something_goes_wrong_with_media_normalization($serializer, ProductInterface $product, FileInfoInterface $media, ProductValueInterface $value, ProductValueInterface $value2, AttributeInterface $attribute)
{
$product->getValues()->willReturn([$value]);
$product->getIdentifier()->willReturn($value2);
$value->getAttribute()->willReturn($attribute);
$value->getData()->willReturn($media);
$value2->getData()->willReturn(23);
$attribute->getAttributeType()->willReturn('pim_catalog_image');
$serializer->normalize([$media], Argument::cetera())->willThrow(new FileNotFoundException('upload/path/img.jpg'));
$this->shouldThrow(new InvalidItemException('The file "upload/path/img.jpg" does not exist', ['item' => 23, 'uploadDirectory' => 'upload/path/']))->duringProcess($product);
}
示例10: prepareQueryCriterias
/**
* Prepare query criteria for variant group
*
* @param GroupInterface $variantGroup
* @param ProductInterface $product
* @param Constraint $constraint
*
* @return array
*/
protected function prepareQueryCriterias(GroupInterface $variantGroup, ProductInterface $product, Constraint $constraint)
{
$criteria = [];
foreach ($variantGroup->getAxisAttributes() as $attribute) {
$value = $product->getValue($attribute->getCode());
// we don't add criteria when option is null, as this check is performed by HasVariantAxesValidator
if (null === $value || null === $value->getOption() && !$attribute->isBackendTypeReferenceData()) {
$this->addEmptyAxisViolation($constraint, $variantGroup->getLabel(), $product->getIdentifier()->getVarchar(), $attribute->getCode());
continue;
}
$current = ['attribute' => $attribute];
if (null !== $value->getOption()) {
$current['option'] = $value->getOption();
} elseif ($attribute->isBackendTypeReferenceData()) {
$current['referenceData'] = ['name' => $attribute->getReferenceDataName(), 'data' => $value->getData()];
}
$criteria[] = $current;
}
return $criteria;
}
示例11:
function it_normalizes_product_with_price($filter, ProductInterface $product, AttributeInterface $priceAttribute, ProductValueInterface $price, Collection $prices, Collection $values, ProductPriceInterface $productPrice, FamilyInterface $family, SerializerInterface $serializer)
{
$family->getCode()->willReturn('shoes');
$priceAttribute->getCode()->willReturn('price');
$priceAttribute->getAttributeType()->willReturn('pim_catalog_price_collection');
$priceAttribute->isLocalizable()->willReturn(false);
$priceAttribute->isScopable()->willReturn(false);
$price->getAttribute()->willReturn($priceAttribute);
$price->getData()->willReturn(null);
$productPrice->getData()->willReturn("356.00");
$productPrice->getCurrency()->willReturn("EUR");
$prices->add($productPrice);
$price->getPrices()->willReturn($prices);
$product->getIdentifier()->willReturn($price);
$product->getFamily()->willReturn($family);
$product->isEnabled()->willReturn(true);
$product->getGroupCodes()->willReturn(['group1', 'group2', 'variant_group_1']);
$product->getCategoryCodes()->willReturn(['nice shoes', 'converse']);
$product->getAssociations()->willReturn([]);
$values->add($price);
$product->getValues()->willReturn($values);
$filter->filterCollection($values, 'pim.transform.product_value.flat', Argument::cetera())->willReturn([$price]);
$serializer->normalize($price, 'flat', Argument::any())->willReturn(['price-EUR' => '356.00']);
$this->normalize($product, 'flat', ['price-EUR' => ''])->shouldReturn(['price-EUR' => '356.00', 'family' => 'shoes', 'groups' => 'group1,group2,variant_group_1', 'categories' => 'nice shoes,converse', 'enabled' => 1]);
}
示例12: fetchMedia
/**
* Fetch medias on the local filesystem
*
* @param ProductInterface $product
* @param string $directory
*/
protected function fetchMedia(ProductInterface $product, $directory)
{
$identifier = $product->getIdentifier()->getData();
$this->mediaFetcher->fetchAll($product->getValues(), $directory, $identifier);
foreach ($this->mediaFetcher->getErrors() as $error) {
$this->stepExecution->addWarning($error['message'], [], new DataInvalidItem($error['media']));
}
}