本文整理汇总了PHP中Magento\Eav\Model\Entity\Attribute::getAttributeCode方法的典型用法代码示例。如果您正苦于以下问题:PHP Attribute::getAttributeCode方法的具体用法?PHP Attribute::getAttributeCode怎么用?PHP Attribute::getAttributeCode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Eav\Model\Entity\Attribute
的用法示例。
在下文中一共展示了Attribute::getAttributeCode方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addOptionValueToCollection
/**
* Add Join with option value for collection select
*
* @param \Magento\Eav\Model\Entity\Collection\AbstractCollection $collection
* @param \Magento\Eav\Model\Entity\Attribute $attribute
* @param \Zend_Db_Expr $valueExpr
* @return $this
*/
public function addOptionValueToCollection($collection, $attribute, $valueExpr)
{
$adapter = $this->_getReadAdapter();
$attributeCode = $attribute->getAttributeCode();
$optionTable1 = $attributeCode . '_option_value_t1';
$optionTable2 = $attributeCode . '_option_value_t2';
$tableJoinCond1 = "{$optionTable1}.option_id={$valueExpr} AND {$optionTable1}.store_id=0";
$tableJoinCond2 = $adapter->quoteInto("{$optionTable2}.option_id={$valueExpr} AND {$optionTable2}.store_id=?", $collection->getStoreId());
$valueExpr = $adapter->getCheckSql("{$optionTable2}.value_id IS NULL", "{$optionTable1}.value", "{$optionTable2}.value");
$collection->getSelect()->joinLeft([$optionTable1 => $this->getTable('eav_attribute_option_value')], $tableJoinCond1, [])->joinLeft([$optionTable2 => $this->getTable('eav_attribute_option_value')], $tableJoinCond2, [$attributeCode => $valueExpr]);
return $this;
}
示例2: getStaticAttributeFilterType
/**
* Determine filter type for static attribute.
*
* @static
* @param \Magento\Eav\Model\Entity\Attribute $attribute
* @return string
*/
public static function getStaticAttributeFilterType(\Magento\Eav\Model\Entity\Attribute $attribute)
{
if (in_array($attribute->getAttributeCode(), ['category_ids', 'media_gallery'])) {
return self::FILTER_TYPE_INPUT;
}
$columns = $attribute->getFlatColumns();
switch ($columns[$attribute->getAttributeCode()]['type']) {
case \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER:
case \Magento\Framework\DB\Ddl\Table::TYPE_BIGINT:
$type = self::FILTER_TYPE_NUMBER;
break;
case \Magento\Framework\DB\Ddl\Table::TYPE_DATE:
case \Magento\Framework\DB\Ddl\Table::TYPE_DATETIME:
case \Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP:
$type = self::FILTER_TYPE_DATE;
break;
default:
$type = self::FILTER_TYPE_INPUT;
}
return $type;
}
示例3: map
/**
* Build attribute representation
*
* @param \Magento\Eav\Model\Entity\Attribute $attribute
* @return array
*/
public function map(\Magento\Eav\Model\Entity\Attribute $attribute)
{
$isUnassignable = !in_array($attribute->getAttributeCode(), $this->unassignableAttributes);
return ['text' => $attribute->getAttributeCode(), 'id' => $attribute->getAttributeId(), 'cls' => $isUnassignable ? 'leaf' : 'system-leaf', 'allowDrop' => false, 'allowDrag' => true, 'leaf' => true, 'is_user_defined' => $attribute->getIsUserDefined(), 'is_unassignable' => $isUnassignable, 'entity_id' => $attribute->getEntityAttributeId()];
}
示例4: setAttributeModel
/**
* Set attribute model to filter
*
* @param \Magento\Eav\Model\Entity\Attribute $attribute
* @return \Magento\Catalog\Model\Layer\Filter\AbstractFilter
*/
public function setAttributeModel($attribute)
{
$this->setRequestVar($attribute->getAttributeCode());
$this->setData('attribute_model', $attribute);
return $this;
}
示例5: getAttributeFieldName
/**
* Retrieve attribute field name
*
*
* @param Attribute $attribute
* @return string
*/
public function getAttributeFieldName($attribute)
{
$name = $attribute->getAttributeCode();
if ($suffix = $this->getForm()->getFieldNameSuffix()) {
$name = $this->getForm()->addSuffixToName($name, $suffix);
}
return $name;
}
示例6: setAttributeObj
public function setAttributeObj(\Magento\Eav\Model\Entity\Attribute $obj)
{
$this->attributeObj = $obj;
$this->code = $obj->getAttributeCode();
return $this;
}
示例7: decorateFilter
/**
* Create filter fields for 'Filter' column.
*
* @param mixed $value
* @param Attribute $row
* @param \Magento\Framework\DataObject $column
* @param boolean $isExport
* @return string
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function decorateFilter($value, Attribute $row, \Magento\Framework\DataObject $column, $isExport)
{
$value = null;
$values = $column->getValues();
if (is_array($values) && isset($values[$row->getAttributeCode()])) {
$value = $values[$row->getAttributeCode()];
}
$code = $row->getAttributeCode();
if (isset($this->_filterTypeByAttrCode[$code])) {
$filterType = $this->_filterTypeByAttrCode[$code];
} else {
$filterType = \Magento\ImportExport\Model\Export::getAttributeFilterType($row);
}
switch ($filterType) {
case \Magento\ImportExport\Model\Export::FILTER_TYPE_SELECT:
$cell = $this->_getSelectHtmlWithValue($row, $value);
break;
case \Magento\ImportExport\Model\Export::FILTER_TYPE_INPUT:
$cell = $this->_getInputHtmlWithValue($row, $value);
break;
case \Magento\ImportExport\Model\Export::FILTER_TYPE_DATE:
$cell = $this->_getDateFromToHtmlWithValue($row, $value);
break;
case \Magento\ImportExport\Model\Export::FILTER_TYPE_NUMBER:
$cell = $this->_getNumberFromToHtmlWithValue($row, $value);
break;
default:
$cell = __('Unknown attribute filter type');
}
return $cell;
}