本文整理汇总了PHP中Pim\Component\Catalog\Model\GroupInterface::getId方法的典型用法代码示例。如果您正苦于以下问题:PHP GroupInterface::getId方法的具体用法?PHP GroupInterface::getId怎么用?PHP GroupInterface::getId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pim\Component\Catalog\Model\GroupInterface
的用法示例。
在下文中一共展示了GroupInterface::getId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
function it_throws_an_error_if_type_is_unknown(GroupInterface $group)
{
$group->setCode('mycode')->shouldBeCalled();
$group->getId()->willReturn(null);
$values = ['code' => 'mycode', 'type' => 'UNKNOWN'];
$this->shouldThrow(new \InvalidArgumentException('Type "UNKNOWN" does not exist'))->during('update', [$group, $values, []]);
}
示例2:
function it_normalize_products($productNormalizer, $versionNormalizer, $versionManager, $localeRepository, $structureVersionProvider, $formProvider, $localizedConverter, ProductInterface $mug, AssociationInterface $upsell, AssociationTypeInterface $groupType, GroupInterface $group, ArrayCollection $groups)
{
$options = ['decimal_separator' => ',', 'date_format' => 'dd/MM/yyyy'];
$productNormalized = ['enabled' => true, 'categories' => ['kitchen'], 'family' => '', 'values' => ['normalized_property' => ['data' => 'a nice normalized property', 'locale' => null, 'scope' => null], 'number' => ['data' => 12.5, 'locale' => null, 'scope' => null], 'metric' => ['data' => 12.5, 'locale' => null, 'scope' => null], 'prices' => ['data' => 12.5, 'locale' => null, 'scope' => null], 'date' => ['data' => '2015-01-31', 'locale' => null, 'scope' => null]]];
$valuesLocalized = ['normalized_property' => ['data' => 'a nice normalized property', 'locale' => null, 'scope' => null], 'number' => ['data' => '12,5000', 'locale' => null, 'scope' => null], 'metric' => ['data' => '12,5000', 'locale' => null, 'scope' => null], 'prices' => ['data' => '12,5', 'locale' => null, 'scope' => null], 'date' => ['data' => '31/01/2015', 'locale' => null, 'scope' => null]];
$productNormalizer->normalize($mug, 'json', $options)->willReturn($productNormalized);
$localizedConverter->convertToLocalizedFormats($productNormalized['values'], $options)->willReturn($valuesLocalized);
$mug->getId()->willReturn(12);
$versionManager->getOldestLogEntry($mug)->willReturn('create_version');
$versionNormalizer->normalize('create_version', 'internal_api')->willReturn('normalized_create_version');
$versionManager->getNewestLogEntry($mug)->willReturn('update_version');
$versionNormalizer->normalize('update_version', 'internal_api')->willReturn('normalized_update_version');
$localeRepository->getActivatedLocaleCodes()->willReturn(['en_US', 'fr_FR']);
$mug->getLabel('en_US')->willReturn('A nice Mug!');
$mug->getLabel('fr_FR')->willReturn('Un très beau Mug !');
$mug->getAssociations()->willReturn([$upsell]);
$upsell->getAssociationType()->willReturn($groupType);
$groupType->getCode()->willReturn('group');
$upsell->getGroups()->willReturn($groups);
$groups->toArray()->willReturn([$group]);
$group->getId()->willReturn(12);
$structureVersionProvider->getStructureVersion()->willReturn(12);
$formProvider->getForm($mug)->willReturn('product-edit-form');
$this->normalize($mug, 'internal_api', $options)->shouldReturn(['enabled' => true, 'categories' => ['kitchen'], 'family' => '', 'values' => $valuesLocalized, 'meta' => ['form' => 'product-edit-form', 'id' => 12, 'created' => 'normalized_create_version', 'updated' => 'normalized_update_version', 'model_type' => 'product', 'structure_version' => 12, 'label' => ['en_US' => 'A nice Mug!', 'fr_FR' => 'Un très beau Mug !'], 'associations' => ['group' => ['groupIds' => [12]]]]]);
}
示例3:
function it_throws_an_exception_if_attribute_is_unknown($attributeRepository, GroupInterface $group)
{
$group->setCode('mycode')->shouldBeCalled();
$attributeRepository->findOneByIdentifier('foo')->willReturn(null);
$group->getId()->willReturn(null);
$values = ['code' => 'mycode', 'axis' => ['foo']];
$this->shouldThrow(new \InvalidArgumentException('Attribute "foo" does not exist'))->during('update', [$group, $values, []]);
}
示例4: Attribute
function it_throws_an_error_if_axis_is_updated(GroupInterface $variantGroup)
{
$variantGroup->setCode('mycode')->shouldBeCalled();
$variantGroup->getId()->willReturn(42);
$attribute = new Attribute();
$attribute->setCode('other');
$variantGroup->getAxisAttributes()->willReturn(new ArrayCollection([$attribute]));
$values = ['code' => 'mycode', 'axis' => ['main_color']];
$this->shouldThrow(new \InvalidArgumentException('Attributes: This property cannot be changed.'))->during('update', [$variantGroup, $values, []]);
}
示例5:
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]);
}
示例6:
function it_adds_a_violation_if_axis_attributes_are_invalid($context, GroupInterface $variantGroup, GroupType $type, VariantGroupAxis $constraint, ConstraintViolationBuilderInterface $violation, AttributeInterface $invalidAxis)
{
$variantGroup->getId()->willReturn(12);
$variantGroup->getType()->willReturn($type);
$variantGroup->getCode()->willReturn('tshirt');
$type->isVariant()->willReturn(true);
$variantGroup->getAxisAttributes()->willReturn([$invalidAxis]);
$invalidAxis->getAttributeType()->willReturn(AttributeTypes::TEXT);
$invalidAxis->getCode()->willReturn('name');
$violationData = ['%group%' => 'tshirt', '%attribute%' => 'name'];
$context->buildViolation($constraint->invalidAxisMessage, $violationData)->shouldBeCalled()->willReturn($violation);
$this->validate($variantGroup, $constraint);
}
示例7:
function it_normalize_products($productNormalizer, $versionNormalizer, $versionManager, $localeRepository, $structureVersionProvider, $formProvider, ProductInterface $mug, AssociationInterface $upsell, AssociationTypeInterface $groupType, GroupInterface $group, ArrayCollection $groups)
{
$productNormalizer->normalize($mug, 'json', [])->willReturn(['normalized_property' => 'a nice normalized property']);
$mug->getId()->willReturn(12);
$versionManager->getOldestLogEntry($mug)->willReturn('create_version');
$versionNormalizer->normalize('create_version', 'internal_api')->willReturn('normalized_create_version');
$versionManager->getNewestLogEntry($mug)->willReturn('update_version');
$versionNormalizer->normalize('update_version', 'internal_api')->willReturn('normalized_update_version');
$localeRepository->getActivatedLocaleCodes()->willReturn(['en_US', 'fr_FR']);
$mug->getLabel('en_US')->willReturn('A nice Mug!');
$mug->getLabel('fr_FR')->willReturn('Un très beau Mug !');
$mug->getAssociations()->willReturn([$upsell]);
$upsell->getAssociationType()->willReturn($groupType);
$groupType->getCode()->willReturn('group');
$upsell->getGroups()->willReturn($groups);
$groups->toArray()->willReturn([$group]);
$group->getId()->willReturn(12);
$structureVersionProvider->getStructureVersion()->willReturn(12);
$formProvider->getForm($mug)->willReturn('product-edit-form');
$this->normalize($mug, 'internal_api', [])->shouldReturn(['normalized_property' => 'a nice normalized property', 'meta' => ['form' => 'product-edit-form', 'id' => 12, 'created' => 'normalized_create_version', 'updated' => 'normalized_update_version', 'model_type' => 'product', 'structure_version' => 12, 'label' => ['en_US' => 'A nice Mug!', 'fr_FR' => 'Un très beau Mug !'], 'associations' => ['group' => ['groupIds' => [12]]]]]);
}
示例8:
function it_does_not_add_violation_when_validating_product_in_groups_with_unique_combination_of_axis_attributes($context, $productRepository, GroupInterface $tShirtVariantGroup, GroupTypeInterface $tShirtGroupType, ProductInterface $redTShirtProduct, AttributeInterface $sizeAttribute, AttributeInterface $colorAttribute, ProductValueInterface $sizeProductValue, ProductValueInterface $redColorProductValue, UniqueVariantAxis $uniqueVariantAxisConstraint)
{
$tShirtVariantGroup->getId()->willReturn(1);
$tShirtVariantGroup->getLabel()->willReturn('TShirts');
$tShirtVariantGroup->getType()->willReturn($tShirtGroupType);
$tShirtGroupType->isVariant()->willReturn(true);
$tShirtVariantGroup->getAxisAttributes()->willReturn([$sizeAttribute, $colorAttribute]);
$sizeAttribute->getCode()->willReturn('size');
$sizeAttribute->isBackendTypeReferenceData()->willReturn(false);
$colorAttribute->getCode()->willReturn('color');
$colorAttribute->isBackendTypeReferenceData()->willReturn(false);
$redTShirtProduct->getVariantGroup()->willReturn($tShirtVariantGroup);
$redTShirtProduct->getId()->willReturn(1);
$redTShirtProduct->getValue('size')->willReturn($sizeProductValue);
$redTShirtProduct->getValue('color')->willReturn($redColorProductValue);
$sizeProductValue->getOption()->willReturn('XL');
$redColorProductValue->getOption()->willReturn('Red');
$criteria = [['attribute' => $sizeAttribute, 'option' => 'XL'], ['attribute' => $colorAttribute, 'option' => 'Red']];
$productRepository->findAllForVariantGroup($tShirtVariantGroup, $criteria)->willReturn([]);
$context->buildViolation()->shouldNotBeCalled(Argument::cetera());
$this->validate($redTShirtProduct, $uniqueVariantAxisConstraint);
}
示例9:
function it_normalizes_an_existing_product_without_family_into_mongodb_document($mongoFactory, $serializer, ProductInterface $product, \MongoId $mongoId, \MongoDate $mongoDate, Association $assoc1, Association $assoc2, CategoryInterface $category1, CategoryInterface $category2, GroupInterface $group1, GroupInterface $group2, ProductValueInterface $value1, ProductValueInterface $value2)
{
$mongoFactory->createMongoId('product1')->willReturn($mongoId);
$mongoFactory->createMongoDate()->willReturn($mongoDate);
$category1->getId()->willReturn(12);
$category2->getId()->willReturn(34);
$group1->getId()->willReturn(56);
$group2->getId()->willReturn(78);
$product->getId()->willReturn('product1');
$product->getCreated()->willReturn(null);
$product->getFamily()->willReturn(null);
$product->isEnabled()->willReturn(true);
$product->getGroups()->willReturn([$group1, $group2]);
$product->getCategories()->willReturn([$category1, $category2]);
$product->getAssociations()->willReturn([$assoc1, $assoc2]);
$product->getValues()->willReturn([$value1, $value2]);
$context = ['_id' => $mongoId];
$serializer->normalize($product, 'mongodb_json')->willReturn(['data' => 'data', 'completenesses' => 'completenesses']);
$serializer->normalize($value1, 'mongodb_document', $context)->willReturn('my_value_1');
$serializer->normalize($value2, 'mongodb_document', $context)->willReturn('my_value_2');
$serializer->normalize($assoc1, 'mongodb_document', $context)->willReturn('my_assoc_1');
$serializer->normalize($assoc2, 'mongodb_document', $context)->willReturn('my_assoc_2');
$this->normalize($product, 'mongodb_document')->shouldReturn(['_id' => $mongoId, 'created' => $mongoDate, 'updated' => $mongoDate, 'enabled' => true, 'groupIds' => [56, 78], 'categoryIds' => [12, 34], 'associations' => ['my_assoc_1', 'my_assoc_2'], 'values' => ['my_value_1', 'my_value_2'], 'normalizedData' => ['data' => 'data'], 'completenesses' => []]);
}
示例10: iShouldBeOnTheProductGroupPage
/**
* @param GroupInterface $group
*
* @Given /^I should be on the ("([^"]*)" product group) page$/
*/
public function iShouldBeOnTheProductGroupPage(GroupInterface $group)
{
$expectedAddress = $this->getPage('ProductGroup edit')->getUrl(['id' => $group->getId()]);
$this->assertAddress($expectedAddress);
}
示例11: getProductCountByGroup
/**
* {@inheritdoc}
*/
public function getProductCountByGroup(GroupInterface $group)
{
$qb = $this->createQueryBuilder('p')->hydrate(false)->field('groupIds')->in([$group->getId()]);
$count = $qb->getQuery()->execute()->count();
return $count;
}
示例12:
function it_normalizes_an_association_with_products_and_groups($mongoFactory, Association $assoc, AssociationTypeInterface $assocType, \MongoId $mongoId, \MongoDBRef $ownerRef, ProductInterface $product1, \MongoDBRef $product1Ref, ProductInterface $product2, \MongoDBRef $product2Ref, GroupInterface $group1, GroupInterface $group2)
{
$assocType->getId()->willReturn(8);
$assoc->getAssociationType()->willReturn($assocType);
$context = ['_id' => '1234abc', 'collection_name' => 'product'];
$mongoFactory->createMongoId()->willReturn($mongoId);
$mongoFactory->createMongoDBRef('product', '1234abc')->willReturn($ownerRef);
$mongoFactory->createMongoDBRef('product', 'product1')->willReturn($product1Ref);
$mongoFactory->createMongoDBRef('product', 'product2')->willReturn($product2Ref);
$product1->getId()->willReturn('product1');
$product2->getId()->willReturn('product2');
$assoc->getProducts()->willReturn([$product1, $product2]);
$group1->getId()->willReturn(1);
$group2->getId()->willReturn(2);
$assoc->getGroups()->willReturn([$group1, $group2]);
$this->normalize($assoc, 'mongodb_document', $context)->shouldReturn(['_id' => $mongoId, 'associationType' => 8, 'owner' => $ownerRef, 'products' => [$product1Ref, $product2Ref], 'groupIds' => [1, 2]]);
}
示例13: ArrayCollection
function it_saves_a_variant_group_and_copies_values_to_products($optionsResolver, $objectManager, $templateApplier, $eventDispatcher, $detacher, GroupInterface $group, GroupType $type, ProductInterface $product, ProductTemplateInterface $template)
{
$optionsResolver->resolveSaveOptions(['copy_values_to_products' => true])->willReturn(['flush' => true, 'copy_values_to_products' => true]);
$group->getId()->willReturn(null);
$group->getType()->willReturn($type);
$group->getCode()->willReturn('my_code');
$objectManager->persist($group)->shouldBeCalled();
$objectManager->flush()->shouldBeCalled();
$type->isVariant()->willReturn(true);
$group->getProductTemplate()->willReturn($template);
$group->getProducts()->willReturn(new ArrayCollection([$product]));
$templateApplier->apply($template, [$product])->shouldBeCalled();
$detacher->detachAll([$product])->shouldBeCalled();
$eventDispatcher->dispatch(StorageEvents::PRE_SAVE, Argument::cetera())->shouldBeCalled();
$eventDispatcher->dispatch(StorageEvents::POST_SAVE, Argument::cetera())->shouldBeCalled();
$this->save($group, ['copy_values_to_products' => true]);
}
示例14: setAxes
/**
* @param GroupInterface $variantGroup
* @param array $axes
*
* @throws \InvalidArgumentException
*/
protected function setAxes(GroupInterface $variantGroup, array $axes)
{
if (null !== $variantGroup->getId()) {
if (array_diff($this->getOriginalAxes($variantGroup->getAxisAttributes()), array_values($axes))) {
throw new \InvalidArgumentException('Attributes: This property cannot be changed.');
}
}
foreach ($axes as $axis) {
$attribute = $this->attributeRepository->findOneByIdentifier($axis);
if (null !== $attribute) {
$variantGroup->addAxisAttribute($attribute);
} else {
throw new \InvalidArgumentException(sprintf('Attribute "%s" does not exist', $axis));
}
}
}
示例15: saveAssociatedProducts
/**
* Save associated products updated by the variant group update
*
* @param GroupInterface $group
*/
protected function saveAssociatedProducts(GroupInterface $group)
{
$productInGroup = $group->getProducts();
$productsToUpdate = $productInGroup->toArray();
$productToUpdateIds = array_map(function ($product) {
return $product->getId();
}, $productsToUpdate);
if (null !== $group->getId()) {
$pqb = $this->productQueryBuilderFactory->create();
$pqb->addFilter('groups.id', Operators::IN_LIST, [$group->getId()]);
$oldProducts = $pqb->execute();
foreach ($oldProducts as $oldProduct) {
if (!in_array($oldProduct->getId(), $productToUpdateIds)) {
$oldProduct->removeGroup($group);
$productsToUpdate[] = $oldProduct;
$productToUpdateIds[] = $oldProduct->getId();
}
}
}
if (!empty($productsToUpdate)) {
$this->productSaver->saveAll($productsToUpdate);
}
}