本文整理汇总了PHP中Pim\Component\Catalog\Model\ProductInterface::getReference方法的典型用法代码示例。如果您正苦于以下问题:PHP ProductInterface::getReference方法的具体用法?PHP ProductInterface::getReference怎么用?PHP ProductInterface::getReference使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pim\Component\Catalog\Model\ProductInterface
的用法示例。
在下文中一共展示了ProductInterface::getReference方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
function it_normalizes_a_product_associations_in_standard_format_only(ProductInterface $product, AssociationInterface $association1, AssociationInterface $association2, AssociationTypeInterface $associationType1, AssociationTypeInterface $associationType2, GroupInterface $group1, ProductInterface $productAssociated)
{
$group1->getCode()->willReturn('group_code');
$associationType1->getCode()->willReturn('XSELL');
$association1->getAssociationType()->willReturn($associationType1);
$association1->getGroups()->willReturn([$group1]);
$association1->getProducts()->willReturn([]);
$productAssociated->getReference()->willReturn('product_code');
$associationType2->getCode()->willReturn('PACK');
$association2->getAssociationType()->willReturn($associationType2);
$association2->getGroups()->willReturn([]);
$association2->getProducts()->willReturn([$productAssociated]);
$product->getAssociations()->willReturn([$association1, $association2]);
$this->normalize($product, 'standard')->shouldReturn(['PACK' => ['groups' => [], 'products' => ['product_code']], 'XSELL' => ['groups' => ['group_code'], 'products' => []]]);
}
示例2: normalize
/**
* {@inheritdoc}
*
* @param ProductInterface $product
*/
public function normalize($product, $format = null, array $context = [])
{
$data = [];
foreach ($product->getAssociations() as $association) {
$code = $association->getAssociationType()->getCode();
$data[$code] = ['groups' => [], 'products' => []];
foreach ($association->getGroups() as $group) {
$data[$code]['groups'][] = $group->getCode();
}
foreach ($association->getProducts() as $product) {
$data[$code]['products'][] = $product->getReference();
}
}
ksort($data);
return $data;
}
示例3:
function it_normalizes_the_associations_of_the_product(ProductInterface $product, AssociationInterface $association1, AssociationInterface $association2, AssociationTypeInterface $type1, AssociationTypeInterface $type2, ProductInterface $productAssociated1, ProductInterface $productAssociated2, ProductInterface $productAssociated3, GroupInterface $groupAssociated1, GroupInterface $groupAssociated2)
{
$type1->getCode()->willReturn('wahou the type');
$type2->getCode()->willReturn('such a type');
$groupAssociated1->getCode()->willReturn('group 1');
$groupAssociated2->getCode()->willReturn('group 2');
$productAssociated1->getReference()->willReturn('product 1');
$productAssociated2->getReference()->willReturn('product 2');
$productAssociated3->getReference()->willReturn('product 3');
$association1->getAssociationType()->willReturn($type1);
$association2->getAssociationType()->willReturn($type2);
$association1->getGroups()->willReturn([$groupAssociated1]);
$association2->getGroups()->willReturn([$groupAssociated1, $groupAssociated2]);
$association1->getProducts()->willReturn([]);
$association2->getProducts()->willReturn([$productAssociated1, $productAssociated2, $productAssociated3]);
$product->getAssociations()->willReturn([$association1, $association2]);
$this->normalize($product, 'json')->shouldReturn(['such a type' => ['groups' => ['group 1', 'group 2'], 'products' => ['product 1', 'product 2', 'product 3']], 'wahou the type' => ['groups' => ['group 1'], 'products' => []]]);
}
示例4:
function it_validates_an_entity_which_has_no_identifier($validator, ProductInterface $product, ColumnInfo $columnInfo, ConstraintViolationList $violationList, \ArrayIterator $iterator)
{
$product->getReference()->willReturn('sku-001');
$columnInfo->getPropertyPath()->willReturn('unique_attribute');
$validator->validate($product)->willReturn($violationList);
$violationList->getIterator()->willReturn($iterator);
$iterator->rewind()->willReturn(null);
$iterator->valid()->willReturn(false);
$iterator->next()->willReturn(null);
$this->validate($product, [$columnInfo], [], [])->shouldReturn([]);
}