本文整理汇总了PHP中Pim\Component\Catalog\Model\ProductInterface::getValue方法的典型用法代码示例。如果您正苦于以下问题:PHP ProductInterface::getValue方法的具体用法?PHP ProductInterface::getValue怎么用?PHP ProductInterface::getValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pim\Component\Catalog\Model\ProductInterface
的用法示例。
在下文中一共展示了ProductInterface::getValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: foreach
function it_copies_simple_select_value_to_a_product_value($builder, $attrValidatorHelper, AttributeInterface $fromAttribute, AttributeInterface $toAttribute, ProductInterface $product1, ProductInterface $product2, ProductInterface $product3, ProductInterface $product4, ProductValueInterface $fromProductValue, ProductValueInterface $toProductValue, AttributeOptionInterface $attributeOption)
{
$fromLocale = 'fr_FR';
$toLocale = 'fr_FR';
$toScope = 'mobile';
$fromScope = 'mobile';
$fromAttribute->getCode()->willReturn('fromAttributeCode');
$toAttribute->getCode()->willReturn('toAttributeCode');
$attrValidatorHelper->validateLocale(Argument::cetera())->shouldBeCalled();
$attrValidatorHelper->validateScope(Argument::cetera())->shouldBeCalled();
$fromProductValue->getData()->willReturn($attributeOption);
$toProductValue->setOption($attributeOption)->shouldBeCalledTimes(3);
$product1->getValue('fromAttributeCode', $fromLocale, $fromScope)->willReturn($fromProductValue);
$product1->getValue('toAttributeCode', $toLocale, $toScope)->willReturn($toProductValue);
$product2->getValue('fromAttributeCode', $fromLocale, $fromScope)->willReturn(null);
$product2->getValue('toAttributeCode', $toLocale, $toScope)->willReturn($toProductValue);
$product3->getValue('fromAttributeCode', $fromLocale, $fromScope)->willReturn($fromProductValue);
$product3->getValue('toAttributeCode', $toLocale, $toScope)->willReturn(null);
$product4->getValue('fromAttributeCode', $fromLocale, $fromScope)->willReturn($fromProductValue);
$product4->getValue('toAttributeCode', $toLocale, $toScope)->willReturn($toProductValue);
$builder->addProductValue($product3, $toAttribute, $toLocale, $toScope)->shouldBeCalledTimes(1)->willReturn($toProductValue);
$products = [$product1, $product2, $product3, $product4];
foreach ($products as $product) {
$this->copyAttributeData($product, $product, $fromAttribute, $toAttribute, ['from_locale' => $fromLocale, 'to_locale' => $toLocale, 'from_scope' => $fromScope, 'to_scope' => $toScope]);
}
}
示例2:
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);
}
示例3:
function it_allows_setting_attribute_data_option_to_null(ProductInterface $product, AttributeInterface $attribute, ProductValueInterface $value)
{
$attribute->getCode()->willReturn('choice');
$product->getValue('choice', 'fr_FR', 'mobile')->shouldBeCalled()->willReturn($value);
$value->setOption(null)->shouldBeCalled();
$this->setAttributeData($product, $attribute, null, ['locale' => 'fr_FR', 'scope' => 'mobile']);
}
示例4: setMedia
/**
* Set media in the product value
*
* @param ProductInterface $product
* @param AttributeInterface $attribute
* @param FileInfoInterface|null $fileInfo
* @param string|null $locale
* @param string|null $scope
*/
protected function setMedia(ProductInterface $product, AttributeInterface $attribute, FileInfoInterface $fileInfo = null, $locale = null, $scope = null)
{
$value = $product->getValue($attribute->getCode(), $locale, $scope);
if (null === $value) {
$value = $this->productBuilder->addProductValue($product, $attribute, $locale, $scope);
}
$value->setMedia($fileInfo);
}
示例5: setOption
/**
* Set option into the product value
*
* @param ProductInterface $product
* @param AttributeInterface $attribute
* @param AttributeOptionInterface|null $option
* @param string|null $locale
* @param string|null $scope
*/
protected function setOption(ProductInterface $product, AttributeInterface $attribute, AttributeOptionInterface $option = null, $locale = null, $scope = null)
{
$value = $product->getValue($attribute->getCode(), $locale, $scope);
if (null === $value) {
$value = $this->productBuilder->addProductValue($product, $attribute, $locale, $scope);
}
$value->setOption($option);
}
示例6: setData
/**
* Set data into product value
*
* @param ProductInterface $product
* @param AttributeInterface $attribute
* @param mixed $data
* @param string $locale
* @param string $scope
*/
protected function setData(ProductInterface $product, AttributeInterface $attribute, $data, $locale, $scope)
{
$value = $product->getValue($attribute->getCode(), $locale, $scope);
if (null === $value) {
$value = $this->productBuilder->addProductValue($product, $attribute, $locale, $scope);
}
$value->setData($data);
}
示例7:
function it_sets_attribute_when_new_value_is_different_from_product_value($builder, AttributeInterface $attribute, ProductInterface $product, FamilyInterface $family, ProductValue $productValue)
{
$family->getAttributeCodes()->willReturn(['sku', 'is_color']);
$product->getFamily()->willReturn($family);
$attribute->getCode()->willReturn('is_color');
$product->getValue('is_color', null, null)->willReturn(null);
$builder->addProductValue($product, $attribute, null, null)->willReturn($productValue);
$this->setAttributeData($product, $attribute, true, ['locale' => null, 'scope' => null]);
}
示例8: let
function let(ProductRepositoryInterface $productRepository, UniqueValuesSet $uniqueValuesSet, ExecutionContextInterface $context, Form $form, ProductInterface $product, ProductValueInterface $value)
{
$this->beConstructedWith($productRepository, $uniqueValuesSet);
$product->getValue('unique_attribute')->willReturn($value);
$form->getData()->willReturn($product);
$context->getPropertyPath()->willReturn(self::PROPERTY_PATH);
$context->getRoot()->willReturn($form);
$this->initialize($context);
}
示例9: removeOptions
/**
* @param ProductInterface $product
* @param AttributeInterface $attribute
* @param array $attributeOptions
* @param string|null $locale
* @param string|null $scope
*/
protected function removeOptions(ProductInterface $product, AttributeInterface $attribute, $attributeOptions, $locale, $scope)
{
$productValue = $product->getValue($attribute->getCode(), $locale, $scope);
if (null !== $productValue) {
foreach ($attributeOptions as $attributeOption) {
$productValue->removeOption($attributeOption);
}
}
}
示例10:
function it_should_removes_an_attribute_data_multi_select_value_to_a_product_value(AttributeInterface $attribute, ProductInterface $product, ProductValueInterface $productValue, AttributeOptionInterface $attributeOption, $attrOptionRepository)
{
$attribute->getCode()->willReturn('tshirt_style');
$attrOptionRepository->findOneByIdentifier('tshirt_style.vneck')->willReturn($attributeOption);
$product->getValue('tshirt_style', 'fr_FR', 'mobile')->willReturn($productValue);
$productValue->removeOption($attributeOption)->shouldBeCalled();
$data = ['vneck'];
$this->removeAttributeData($product, $attribute, $data, ['locale' => 'fr_FR', 'scope' => 'mobile']);
}
示例11: getImagePath
/**
* Returns the image path for an attribute of a product. If no image is found, returns null.
*
* @param ProductInterface $product
* @param AttributeInterface $attribute
* @param string $locale
* @param string $scope
*
* @return string|null
*/
public function getImagePath(ProductInterface $product, AttributeInterface $attribute, $locale, $scope)
{
$productValue = $product->getValue($attribute->getCode(), $locale, $scope);
$path = null;
if (null !== $productValue->getMedia() && null !== $productValue->getMedia()->getKey()) {
$path = sprintf('media/cache/thumbnail/%s', $productValue->getMedia()->getKey());
}
return $path;
}
示例12: addOptions
/**
* Adds options into the product value
*
* @param ProductInterface $product
* @param AttributeInterface $attribute
* @param array $attributeOptions
* @param string $locale
* @param string $scope
*/
protected function addOptions(ProductInterface $product, AttributeInterface $attribute, $attributeOptions, $locale, $scope)
{
$value = $product->getValue($attribute->getCode(), $locale, $scope);
if (null === $value) {
$value = $this->productBuilder->addProductValue($product, $attribute, $locale, $scope);
}
foreach ($attributeOptions as $attributeOption) {
$value->addOption($attributeOption);
}
}
示例13: removePrices
/**
* Remove prices from product value
*
* @param ProductInterface $product
* @param AttributeInterface $attribute
* @param mixed $data
* @param string $locale
* @param string $scope
*/
protected function removePrices(ProductInterface $product, AttributeInterface $attribute, $data, $locale, $scope)
{
$productValue = $product->getValue($attribute->getCode(), $locale, $scope);
if (null !== $productValue) {
foreach ($data as $price) {
$priceToRemove = $productValue->getPrice($price['currency']);
$productValue->removePrice($priceToRemove);
}
}
}
示例14:
function it_sets_null_value_when_receiving_empty_string(AttributeInterface $attribute, ProductInterface $product1, ProductInterface $product2, ProductInterface $product3, $builder, ProductValue $productValue)
{
$locale = 'fr_FR';
$scope = 'mobile';
$data = '';
$attribute->getCode()->willReturn('attributeCode');
$productValue->setData(null)->shouldBeCalled();
$builder->addProductValue($product2, $attribute, $locale, $scope)->willReturn($productValue);
$product1->getValue('attributeCode', $locale, $scope)->shouldBeCalled()->willReturn($productValue);
$this->setAttributeData($product1, $attribute, $data, ['locale' => $locale, 'scope' => $scope]);
}
示例15: copySingleValue
/**
* Copy single value
*
* @param ProductInterface $fromProduct
* @param ProductInterface $toProduct
* @param AttributeInterface $fromAttribute
* @param AttributeInterface $toAttribute
* @param string $fromLocale
* @param string $toLocale
* @param string $fromScope
* @param string $toScope
*/
protected function copySingleValue(ProductInterface $fromProduct, ProductInterface $toProduct, AttributeInterface $fromAttribute, AttributeInterface $toAttribute, $fromLocale, $toLocale, $fromScope, $toScope)
{
$fromValue = $fromProduct->getValue($fromAttribute->getCode(), $fromLocale, $fromScope);
if (null !== $fromValue) {
$toValue = $toProduct->getValue($toAttribute->getCode(), $toLocale, $toScope);
if (null === $toValue) {
$toValue = $this->productBuilder->addProductValue($toProduct, $toAttribute, $toLocale, $toScope);
}
$this->copyOptions($fromValue, $toValue);
}
}