本文整理汇总了PHP中Pim\Bundle\CatalogBundle\Model\ProductInterface::getValue方法的典型用法代码示例。如果您正苦于以下问题:PHP ProductInterface::getValue方法的具体用法?PHP ProductInterface::getValue怎么用?PHP ProductInterface::getValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pim\Bundle\CatalogBundle\Model\ProductInterface
的用法示例。
在下文中一共展示了ProductInterface::getValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: foreach
function it_copies_multi_select_value_to_a_product_value($builder, $attrValidatorHelper, AttributeInterface $fromAttribute, AttributeInterface $toAttribute, ProductInterface $product1, ProductInterface $product2, ProductInterface $product3, ProductInterface $product4, ProductValue $fromProductValue, ProductValue $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->getOptions()->willReturn([$attributeOption])->shouldBeCalled(3);
$toProductValue->getOptions()->willReturn([$attributeOption]);
$toProductValue->removeOption($attributeOption)->shouldBeCalled();
$toProductValue->addOption($attributeOption)->shouldBeCalled();
$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: foreach
function it_copies_a_price_collection_value_to_a_product_value($builder, $attrValidatorHelper, AttributeInterface $fromAttribute, AttributeInterface $toAttribute, ProductInterface $product1, ProductInterface $product2, ProductInterface $product3, ProductInterface $product4, ProductValue $fromProductValue, ProductValue $toProductValue, ProductPriceInterface $price)
{
$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([$price]);
$price->getCurrency()->willReturn('USD');
$price->getData()->willReturn(123);
$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);
$builder->addPriceForCurrencyWithData($toProductValue, 'USD', 123)->shouldBeCalled();
$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]);
}
}
示例3: copySingleValue
/**
* Copy single value
*
* @param ProductInterface $product
* @param AttributeInterface $fromAttribute
* @param AttributeInterface $toAttribute
* @param string $fromLocale
* @param string $toLocale
* @param string $fromScope
* @param string $toScope
*/
protected function copySingleValue(ProductInterface $product, AttributeInterface $fromAttribute, AttributeInterface $toAttribute, $fromLocale, $toLocale, $fromScope, $toScope)
{
$fromValue = $product->getValue($fromAttribute->getCode(), $fromLocale, $fromScope);
if (null !== $fromValue) {
$toValue = $product->getValue($toAttribute->getCode(), $toLocale, $toScope);
if (null === $toValue) {
$toValue = $this->productBuilder->addProductValue($product, $toAttribute, $toLocale, $toScope);
}
$this->copyOptions($fromValue, $toValue);
}
}
示例4:
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);
}
示例5:
function it_allows_setting_option_to_null(ProductInterface $product, AttributeInterface $attribute, ProductValueInterface $value)
{
$attribute->getCode()->willReturn('choice');
$product->getValue('choice', null, null)->shouldBeCalled()->willReturn($value);
$value->setOption(null)->shouldBeCalled();
$this->setValue([$product], $attribute, null);
}
示例6:
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']);
}
示例7:
function it_creates_and_sets_geolocation_to_product_value($productBuilder, ProductInterface $product, AttributeInterface $attribute, ProductValueInterface $value)
{
$attribute->getCode()->shouldBeCalled()->willReturn('geolocation');
$product->getValue('geolocation', 'FR', 'master')->shouldBeCalled()->willReturn(null);
$productBuilder->addProductValue($product, $attribute, 'FR', 'master')->shouldBeCalled()->willReturn($value);
$value->setData(Argument::type('CleverAge\\Bundle\\GeolocAttributeBundle\\Model\\Geolocation'))->shouldBeCalled();
$this->setValue([$product], $attribute, ['latitude' => 12, 'longitude' => 12], 'FR', 'master');
}
示例8: 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);
}
示例9: copySingleValue
/**
* @param ProductInterface $product
* @param AttributeInterface $fromAttribute
* @param AttributeInterface $toAttribute
* @param string $fromLocale
* @param string $toLocale
* @param string $fromScope
* @param string $toScope
*/
protected function copySingleValue(ProductInterface $product, AttributeInterface $fromAttribute, AttributeInterface $toAttribute, $fromLocale, $toLocale, $fromScope, $toScope)
{
$fromValue = $product->getValue($fromAttribute->getCode(), $fromLocale, $fromScope);
if (null !== $fromValue) {
$fromData = $fromValue->getData();
$toValue = $product->getValue($toAttribute->getCode(), $toLocale, $toScope);
if (null === $toValue) {
$toValue = $this->productBuilder->addProductValue($product, $toAttribute, $toLocale, $toScope);
}
if (null === ($metric = $toValue->getMetric())) {
$metric = $this->metricFactory->createMetric($fromData->getFamily());
}
$metric->setUnit($fromData->getUnit());
$metric->setData($fromData->getData());
$toValue->setMetric($metric);
}
}
示例10: 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);
}
示例11: 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);
}
示例12: 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;
}
示例13: 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);
}
示例14: let
function let(ProductManager $productManager, ExecutionContextInterface $context, Form $form, ProductInterface $product, ProductValueInterface $value)
{
$this->beConstructedWith($productManager);
$product->getValue('sku')->willReturn($value);
$form->getData()->willReturn($product);
$context->getPropertyPath()->willReturn(self::PROPERTY_PATH);
$context->getRoot()->willReturn($form);
$this->initialize($context);
}
示例15: 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);
}
}