本文整理汇总了PHP中Pim\Component\Catalog\Model\AttributeInterface::isBackendTypeReferenceData方法的典型用法代码示例。如果您正苦于以下问题:PHP AttributeInterface::isBackendTypeReferenceData方法的具体用法?PHP AttributeInterface::isBackendTypeReferenceData怎么用?PHP AttributeInterface::isBackendTypeReferenceData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pim\Component\Catalog\Model\AttributeInterface
的用法示例。
在下文中一共展示了AttributeInterface::isBackendTypeReferenceData方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addData
/**
* {@inheritdoc}
*/
public function addData($data)
{
$backendType = $this->attribute->getBackendType();
if ($this->attribute->isBackendTypeReferenceData()) {
$backendType = $this->attribute->getReferenceDataName();
}
if (substr($backendType, -1, 1) === 's') {
$backendType = substr($backendType, 0, strlen($backendType) - 1);
}
$name = 'add' . ucfirst($backendType);
return $this->{$name}($data);
}
示例2:
function it_sets_the_locale_and_scope_when_denormalizing_values($serializer, AttributeInterface $attribute)
{
$attribute->getAttributeType()->willReturn('pim_catalog_number');
$attribute->getBackendType()->willReturn('decimal');
$attribute->isBackendTypeReferenceData()->willReturn(false);
$attribute->isLocalizable()->willReturn(true);
$attribute->isScopable()->willReturn(true);
$serializer->denormalize(1, 'pim_catalog_number', 'json', Argument::type('array'))->shouldBeCalled()->willReturn(1);
$value = $this->denormalize(['data' => 1, 'locale' => 'en_US', 'scope' => 'ecommerce'], 'Pim\\Component\\Catalog\\Model\\ProductValue', 'json', ['attribute' => $attribute]);
$value->shouldBeAnInstanceOf('Pim\\Component\\Catalog\\Model\\ProductValue');
$value->getData()->shouldReturn(1);
$value->getLocale()->shouldReturn('en_US');
$value->getScope()->shouldReturn('ecommerce');
}
示例3:
function it_adds_a_violation_when_validating_product_in_groups_with_non_unique_combination_of_axis_attributes($context, $productRepository, GroupInterface $tShirtVariantGroup, ProductInterface $redTShirtProduct, AttributeInterface $sizeAttribute, AttributeInterface $colorAttribute, ProductValueInterface $sizeProductValue, ProductValueInterface $colorProductValue, ProductInterface $redTShirtProduct2, UniqueVariantAxis $uniqueVariantAxisConstraint, ConstraintViolationBuilderInterface $violation)
{
$redTShirtProduct->getVariantGroup()->willReturn($tShirtVariantGroup);
$tShirtVariantGroup->getId()->willReturn(1);
$tShirtVariantGroup->getLabel()->willReturn('TShirts');
$tShirtVariantGroup->getAxisAttributes()->willReturn([$sizeAttribute, $colorAttribute]);
$sizeAttribute->getCode()->willReturn('size');
$sizeAttribute->isBackendTypeReferenceData()->willReturn(true);
$sizeAttribute->getReferenceDataName()->willReturn('ref_size');
$colorAttribute->getCode()->willReturn('color');
$colorAttribute->isBackendTypeReferenceData()->willReturn(true);
$colorAttribute->getReferenceDataName()->willReturn('ref_color');
$redTShirtProduct->getValue('size')->willReturn($sizeProductValue);
$redTShirtProduct->getValue('color')->willReturn($colorProductValue);
$redTShirtProduct->getId()->willReturn(1);
$sizeProductValue->getData()->willReturn('XL');
$sizeProductValue->getOption()->willReturn(null);
$colorProductValue->getData()->willReturn('Red');
$colorProductValue->getOption()->willReturn(null);
$criteria = [['attribute' => $sizeAttribute, 'referenceData' => ['name' => 'ref_size', 'data' => 'XL']], ['attribute' => $colorAttribute, 'referenceData' => ['name' => 'ref_color', 'data' => 'Red']]];
$productRepository->findAllForVariantGroup($tShirtVariantGroup, $criteria)->shouldBeCalled()->willReturn([$redTShirtProduct2]);
$context->buildViolation('Group "%variant group%" already contains another product with values "%values%"', ['%variant group%' => 'TShirts', '%values%' => 'size: XL, color: Red'])->shouldBeCalled()->willReturn($violation);
$this->validate($redTShirtProduct, $uniqueVariantAxisConstraint);
}
示例4: getFilterInformationForAttribute
/**
* Returns available information for the attribute and filters which supports it
*
* @param AttributeInterface $attribute
* @param array $attributeFilters
*
* @return array
*/
protected function getFilterInformationForAttribute(AttributeInterface $attribute, array $attributeFilters)
{
$field = $attribute->getCode();
$attributeType = $attribute->getAttributeType();
$isLocalizable = $attribute->isLocalizable() ? 'yes' : 'no';
$isScopable = $attribute->isScopable() ? 'yes' : 'no';
$newEntries = [];
if (array_key_exists($attributeType, $attributeFilters)) {
foreach ($attributeFilters[$attributeType] as $filter) {
$class = get_class($filter);
$operators = implode(', ', $filter->getOperators());
$newEntries[] = [$field, $isLocalizable, $isScopable, $attributeType, $operators, $class];
}
return $newEntries;
}
if ($attribute->isBackendTypeReferenceData()) {
foreach ($this->registry->getAttributeFilters() as $filter) {
if ($filter->supportsAttribute($attribute)) {
$class = get_class($filter);
$operators = implode(', ', $filter->getOperators());
$newEntries[] = [$field, $isLocalizable, $isScopable, $attributeType, $operators, $class];
}
}
return $newEntries;
}
return [[$field, $isLocalizable, $isScopable, $attributeType, '', 'Not supported']];
}