本文整理汇总了PHP中Pim\Bundle\CatalogBundle\Model\GroupInterface::getCode方法的典型用法代码示例。如果您正苦于以下问题:PHP GroupInterface::getCode方法的具体用法?PHP GroupInterface::getCode怎么用?PHP GroupInterface::getCode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pim\Bundle\CatalogBundle\Model\GroupInterface
的用法示例。
在下文中一共展示了GroupInterface::getCode方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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]);
}
}
示例2:
function it_provides_formatted_batch_config_for_the_job(GroupInterface $oroTshirt)
{
$oroTshirt->getCode()->willReturn('oro_tshirt');
$this->setGroup($oroTshirt);
$this->setFilters([['id', 'IN', ['22', '7']]]);
$this->getBatchConfig()->shouldReturn('{\\"filters\\":[[\\"id\\",\\"IN\\",[\\"22\\",\\"7\\"]]],\\"actions\\":{\\"field\\":\\"variant_group\\",\\"value\\":\\"oro_tshirt\\"}}');
}
示例3: validateAttributeAxis
/**
* @param VariantGroupAxis $constraint
* @param GroupInterface $variantGroup
*/
protected function validateAttributeAxis(VariantGroupAxis $constraint, GroupInterface $variantGroup)
{
$allowedTypes = [AttributeTypes::OPTION_SIMPLE_SELECT, AttributeTypes::REFERENCE_DATA_SIMPLE_SELECT];
foreach ($variantGroup->getAxisAttributes() as $attribute) {
if (!in_array($attribute->getAttributeType(), $allowedTypes)) {
$this->addInvalidAxisViolation($constraint, $variantGroup->getCode(), $attribute->getCode());
}
}
}
示例4: 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);
}
示例5:
function it_adds_a_violation_if_a_group_contains_axis_attributes($context, GroupInterface $group, GroupType $type, VariantGroupAxis $constraint, AttributeInterface $axis)
{
$group->getId()->willReturn(null);
$group->getType()->willReturn($type);
$group->getCode()->willReturn('xsell');
$type->isVariant()->willReturn(false);
$group->getAxisAttributes()->willReturn([$axis]);
$violationData = ['%group%' => 'xsell'];
$context->addViolation($constraint->unexpectedAxisMessage, $violationData)->shouldBeCalled();
$this->validate($group, $constraint);
}
示例6:
function it_provides_formatted_batch_config_for_the_job(GroupInterface $officeGroup, GroupInterface $bedroomGroup, ArrayCollection $groupCollection)
{
$officeGroup->getCode()->willReturn('office_room');
$bedroomGroup->getCode()->willReturn('bedroom');
$groupCollection->add($officeGroup);
$groupCollection->add($bedroomGroup);
$this->setGroups($groupCollection);
$groupCollection->map(Argument::type('closure'))->willReturn($groupCollection);
$groupCollection->toArray()->willReturn(['office_room', 'bedroom']);
$this->setFilters([['id', 'IN', ['22', '7']]]);
$this->getBatchConfig()->shouldReturn('{\\"filters\\":[[\\"id\\",\\"IN\\",[\\"22\\",\\"7\\"]]],\\"actions\\":[{\\"field\\":\\"groups\\",\\"value\\":[\\"office_room\\",\\"bedroom\\"]}]}');
}
示例7:
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);
}
示例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->addViolation($constraint->message, array('%group%' => $variantGroup->getCode(), '%attributes%' => $this->formatValues($invalidAttrCodes)));
}
}
示例9:
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);
}
示例10:
function it_saves_a_variant_group_and_copies_values_to_products($optionsResolver, $objectManager, $templateApplier, GroupInterface $group, GroupType $type, ProductInterface $product, ProductTemplateInterface $template, ArrayCollection $products)
{
$optionsResolver->resolveSaveOptions(['copy_values_to_products' => true])->willReturn(['flush' => true, 'copy_values_to_products' => true, 'add_products' => [], 'remove_products' => []]);
$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($products);
$products->toArray()->willReturn([$product]);
$templateApplier->apply($template, [$product])->shouldBeCalled();
$this->save($group, ['copy_values_to_products' => true]);
}
示例11:
function it_adds_a_violation_if_variant_group_template_contains_a_unique_attribute(GroupInterface $variantGroup, GroupType $type, ProductTemplateInterface $template, VariantGroupValues $constraint, $attributeRepository, $context)
{
$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->addViolation($constraint->message, $violationData)->shouldBeCalled();
$this->validate($variantGroup, $constraint);
$template->getValuesData()->willReturn(['sku' => 'SKU-001', 'barcode' => 01122334455]);
$violationData = ['%group%' => 'tshirt', '%attributes%' => '"sku", "barcode"'];
$context->addViolation($constraint->message, $violationData)->shouldBeCalled();
$this->validate($variantGroup, $constraint);
}
示例12:
function it_normalizes_product_with_associations($filter, ProductInterface $product, AttributeInterface $skuAttribute, ProductValueInterface $sku, Association $myCrossSell, AssociationTypeInterface $crossSell, Association $myUpSell, AssociationTypeInterface $upSell, GroupInterface $associatedGroup1, GroupInterface $associatedGroup2, ProductInterface $associatedProduct1, ProductInterface $associatedProduct2, ProductValueInterface $skuAssocProduct1, ProductValueInterface $skuAssocProduct2, Collection $values, FamilyInterface $family, $serializer)
{
$family->getCode()->willReturn('shoes');
$skuAttribute->getCode()->willReturn('sku');
$skuAttribute->getAttributeType()->willReturn('pim_catalog_identifier');
$skuAttribute->isLocalizable()->willReturn(false);
$skuAttribute->isScopable()->willReturn(false);
$sku->getAttribute()->willReturn($skuAttribute);
$sku->getData()->willReturn('sku-001');
$crossSell->getCode()->willReturn('cross_sell');
$myCrossSell->getAssociationType()->willReturn($crossSell);
$myCrossSell->getGroups()->willReturn([]);
$myCrossSell->getProducts()->willReturn([]);
$upSell->getCode()->willReturn('up_sell');
$myUpSell->getAssociationType()->willReturn($upSell);
$associatedGroup1->getCode()->willReturn('associated_group1');
$associatedGroup2->getCode()->willReturn('associated_group2');
$myUpSell->getGroups()->willReturn([$associatedGroup1, $associatedGroup2]);
$skuAssocProduct1->getAttribute()->willReturn($skuAttribute);
$skuAssocProduct2->getAttribute()->willReturn($skuAttribute);
$skuAssocProduct1->__toString()->willReturn('sku_assoc_product1');
$skuAssocProduct2->__toString()->willReturn('sku_assoc_product2');
$associatedProduct1->getIdentifier()->willReturn($skuAssocProduct1);
$associatedProduct2->getIdentifier()->willReturn($skuAssocProduct2);
$myUpSell->getProducts()->willReturn([$associatedProduct1, $associatedProduct2]);
$product->getIdentifier()->willReturn($sku);
$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([$myCrossSell, $myUpSell]);
$product->getValues()->willReturn($values);
$filter->filterCollection($values, 'pim.transform.product_value.flat', Argument::cetera())->willReturn([$sku]);
$serializer->normalize($sku, 'flat', Argument::any())->willReturn(['sku' => 'sku-001']);
$this->normalize($product, 'flat', [])->shouldReturn(['sku' => 'sku-001', 'family' => 'shoes', 'groups' => 'group1,group2,variant_group_1', 'categories' => 'nice shoes, converse', 'cross_sell-groups' => '', 'cross_sell-products' => '', 'up_sell-groups' => 'associated_group1,associated_group2', 'up_sell-products' => 'sku_assoc_product1,sku_assoc_product2', 'enabled' => 1]);
}
示例13:
function it_normalizes_group($normalizer, GroupInterface $group)
{
$group->getCode()->willReturn('mongo');
$normalizer->normalize($group, 'mongodb_json', [])->willReturn(['label' => 'translations']);
$this->normalize($group, 'mongodb_json', [])->shouldReturn(['code' => 'mongo', 'label' => 'translations']);
}
示例14: getGroupAttributeCodes
/**
* Returns the attribute codes for a group
*
* @param GroupInterface $group
*
* @return array
*/
protected function getGroupAttributeCodes(GroupInterface $group)
{
$code = $group->getCode();
if (!isset($this->groupAttributeCodes[$code])) {
$this->groupAttributeCodes[$code] = $this->getAttributeCodes($group);
}
return $this->groupAttributeCodes[$code];
}