本文整理汇总了PHP中Magento\Eav\Model\Entity\Attribute::getStoreLabel方法的典型用法代码示例。如果您正苦于以下问题:PHP Attribute::getStoreLabel方法的具体用法?PHP Attribute::getStoreLabel怎么用?PHP Attribute::getStoreLabel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Eav\Model\Entity\Attribute
的用法示例。
在下文中一共展示了Attribute::getStoreLabel方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _addSearchCriteria
/**
* Add data about search criteria to object state
*
* @param EntityAttribute $attribute
* @param mixed $value
* @return $this
*/
protected function _addSearchCriteria($attribute, $value)
{
$name = $attribute->getStoreLabel();
if (is_array($value)) {
if (isset($value['from']) && isset($value['to'])) {
if (!empty($value['from']) || !empty($value['to'])) {
if (isset($value['currency'])) {
/** @var $currencyModel Currency */
$currencyModel = $this->_currencyFactory->create()->load($value['currency']);
$from = $currencyModel->format($value['from'], array(), false);
$to = $currencyModel->format($value['to'], array(), false);
} else {
$currencyModel = null;
}
if (strlen($value['from']) > 0 && strlen($value['to']) > 0) {
// -
$value = sprintf('%s - %s', $currencyModel ? $from : $value['from'], $currencyModel ? $to : $value['to']);
} elseif (strlen($value['from']) > 0) {
// and more
$value = __('%1 and greater', $currencyModel ? $from : $value['from']);
} elseif (strlen($value['to']) > 0) {
// to
$value = __('up to %1', $currencyModel ? $to : $value['to']);
}
} else {
return $this;
}
}
}
if (($attribute->getFrontendInput() == 'select' || $attribute->getFrontendInput() == 'multiselect') && is_array($value)) {
foreach ($value as $key => $val) {
$value[$key] = $attribute->getSource()->getOptionText($val);
if (is_array($value[$key])) {
$value[$key] = $value[$key]['label'];
}
}
$value = implode(', ', $value);
} elseif ($attribute->getFrontendInput() == 'select' || $attribute->getFrontendInput() == 'multiselect') {
$value = $attribute->getSource()->getOptionText($value);
if (is_array($value)) {
$value = $value['label'];
}
} elseif ($attribute->getFrontendInput() == 'boolean') {
$value = $value == 1 ? __('Yes') : __('No');
}
$this->_searchCriterias[] = array('name' => $name, 'value' => $value);
return $this;
}
示例2: addSearchCriteria
/**
* @param EntityAttribute $attribute
* @param mixed $value
* @return void
*/
protected function addSearchCriteria($attribute, $value)
{
if (!empty($value)) {
$this->_searchCriterias[] = ['name' => $attribute->getStoreLabel(), 'value' => $value];
}
}