本文整理匯總了PHP中Pim\Component\Catalog\Model\ProductValueInterface::getProduct方法的典型用法代碼示例。如果您正苦於以下問題:PHP ProductValueInterface::getProduct方法的具體用法?PHP ProductValueInterface::getProduct怎麽用?PHP ProductValueInterface::getProduct使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Pim\Component\Catalog\Model\ProductValueInterface
的用法示例。
在下文中一共展示了ProductValueInterface::getProduct方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1:
function it_does_not_add_value_if_already_present(ProductValueInterface $notPresent, ProductInterface $product, AttributeInterface $attribute, ProductValueInterface $present, ProductInterface $anotherProduct)
{
$notPresent->getProduct()->willReturn($product);
$notPresent->getData()->willReturn('new-data');
$notPresent->getAttribute()->willReturn($attribute);
$notPresent->getLocale()->willReturn(null);
$notPresent->getScope()->willReturn(null);
$attribute->getCode()->willReturn('sku');
$this->addValue($notPresent)->shouldReturn(true);
$present->getProduct()->willReturn($anotherProduct);
$present->getData()->willReturn('new-data');
$present->getAttribute()->willReturn($attribute);
$present->getLocale()->willReturn(null);
$present->getScope()->willReturn(null);
$attribute->getCode()->willReturn('sku');
$this->addValue($present)->shouldReturn(false);
}
示例2: addValue
/**
* Return true if value has been added, else if value already exists inside the set
*
* @param ProductValueInterface $productValue
*
* @return bool
*/
public function addValue(ProductValueInterface $productValue)
{
$product = $productValue->getProduct();
$productIdentifier = $this->getProductIdentifier($product);
$productValueData = $this->getValueData($productValue);
$uniqueValueCode = $this->getUniqueValueCode($productValue);
if (isset($this->uniqueValues[$uniqueValueCode][$productValueData])) {
$storedIdentifier = $this->uniqueValues[$uniqueValueCode][$productValueData];
if ($storedIdentifier !== $productIdentifier) {
return false;
}
}
if (!isset($this->uniqueValues[$uniqueValueCode])) {
$this->uniqueValues[$uniqueValueCode] = [];
}
if (!isset($this->uniqueValues[$uniqueValueCode][$productValueData])) {
$this->uniqueValues[$uniqueValueCode][$productValueData] = $productIdentifier;
}
return true;
}
示例3: hasAlreadyValidatedTheSameValue
/**
* Checks if the same exact value has already been processed on a different product instance
*
* When validates values for a VariantGroup there is not product related to the value
*
* @param ProductValueInterface $productValue
*
* @return bool
*/
protected function hasAlreadyValidatedTheSameValue(ProductValueInterface $productValue)
{
if (null !== $productValue->getProduct()) {
return false === $this->uniqueValuesSet->addValue($productValue);
}
return false;
}