本文整理匯總了PHP中Pim\Component\Catalog\Model\ProductValueInterface::removeOption方法的典型用法代碼示例。如果您正苦於以下問題:PHP ProductValueInterface::removeOption方法的具體用法?PHP ProductValueInterface::removeOption怎麽用?PHP ProductValueInterface::removeOption使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Pim\Component\Catalog\Model\ProductValueInterface
的用法示例。
在下文中一共展示了ProductValueInterface::removeOption方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1:
function it_sets_attribute_data_on_multiselect_value_to_a_product_value($builder, $attrOptionRepository, AttributeInterface $attribute, ProductInterface $product1, ProductInterface $product2, ProductInterface $product3, ProductValueInterface $productValue, AttributeOptionInterface $attributeOption, AttributeOptionInterface $oldOption)
{
$locale = 'fr_FR';
$scope = 'mobile';
$attribute->getCode()->willReturn('attributeCode');
$attributeOption->getCode()->willReturn('attributeOptionCode');
$attrOptionRepository->findOneByIdentifier('attributeCode.attributeOptionCode')->shouldBeCalledTimes(3)->willReturn($attributeOption);
$productValue->getOptions()->willReturn([$oldOption]);
$productValue->removeOption($oldOption)->shouldBeCalled();
$productValue->addOption($attributeOption)->shouldBeCalled();
$builder->addProductValue($product2, $attribute, $locale, $scope)->willReturn($productValue);
$product1->getValue('attributeCode', $locale, $scope)->shouldBeCalled()->willReturn($productValue);
$product2->getValue('attributeCode', $locale, $scope)->shouldBeCalled()->willReturn(null);
$product3->getValue('attributeCode', $locale, $scope)->shouldBeCalled()->willReturn($productValue);
$this->setAttributeData($product1, $attribute, ['attributeOptionCode'], ['locale' => $locale, 'scope' => $scope]);
$this->setAttributeData($product2, $attribute, ['attributeOptionCode'], ['locale' => $locale, 'scope' => $scope]);
$this->setAttributeData($product3, $attribute, ['attributeOptionCode'], ['locale' => $locale, 'scope' => $scope]);
}
示例2: removeOptions
/**
* Remove options from attribute
*
* @param ProductValueInterface $toValue
*/
protected function removeOptions(ProductValueInterface $toValue)
{
foreach ($toValue->getOptions() as $attributeOption) {
$toValue->removeOption($attributeOption);
}
}