本文整理汇总了PHP中Pim\Component\Catalog\Model\GroupInterface::addAxisAttribute方法的典型用法代码示例。如果您正苦于以下问题:PHP GroupInterface::addAxisAttribute方法的具体用法?PHP GroupInterface::addAxisAttribute怎么用?PHP GroupInterface::addAxisAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pim\Component\Catalog\Model\GroupInterface
的用法示例。
在下文中一共展示了GroupInterface::addAxisAttribute方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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, []);
}
示例2: 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));
}
}
}