本文整理匯總了PHP中Pim\Bundle\CatalogBundle\Model\ProductInterface::getLabel方法的典型用法代碼示例。如果您正苦於以下問題:PHP ProductInterface::getLabel方法的具體用法?PHP ProductInterface::getLabel怎麽用?PHP ProductInterface::getLabel使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Pim\Bundle\CatalogBundle\Model\ProductInterface
的用法示例。
在下文中一共展示了ProductInterface::getLabel方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getDefaultDrupalProduct
/**
* @param $product
* @return array
*/
public function getDefaultDrupalProduct(ProductInterface $product)
{
$labels = [];
$attributeAsLabel = $product->getFamily()->getAttributeAsLabel();
$availableLocales = $attributeAsLabel->getAvailableLocales();
if (!is_null($availableLocales)) {
foreach ($availableLocales as $availableLocale) {
$labels[$availableLocale->getCode()] = $product->getLabel($availableLocale->getCode());
}
}
// TODO: fix availableLocales doesn t must be NULL
foreach ($attributeAsLabel->getTranslations() as $translation) {
$labels[$translation->getLocale()] = $product->getLabel($translation->getLocale());
}
$defaultDrupalProduct = ['sku' => $product->getReference(), 'family' => $product->getFamily()->getCode(), 'created' => $product->getCreated()->format('c'), 'updated' => $product->getUpdated()->format('c'), 'status' => $product->isEnabled(), 'labels' => $labels, 'categories' => [], 'groups' => [], 'associations' => [], 'values' => []];
return $defaultDrupalProduct;
}
示例2: getLabels
/**
* @param ProductInterface $product
*
* @return array
*/
protected function getLabels(ProductInterface $product)
{
$labels = [];
foreach ($this->localeRepository->getActivatedLocaleCodes() as $localeCode) {
$labels[$localeCode] = $product->getLabel($localeCode);
}
return ['label' => $labels];
}