Есть ли способ узнать, что делает каждый аргумент атрибута?


Что я хочу знать, так это то, сколько именно аргументов имеет атрибут и как мы можем узнать, что делает каждый аргумент ?

Например, Рассмотрите возможность добавления атрибута для клиента.

Вот код, в котором вы можете найти некоторые параметры.

$customerSetup->addAttribute(\Magento\Customer\Model\Customer::ENTITY, "verified_buyer",  array(
            "type"     => "integer",
            "backend"  => "",
            "label"    => "Verified Buyer",
            "input"    => "checkbox",
            "source"   => "",
            "visible"  => true,
            "required" => false,
            "default" => 0,
            "frontend" => "",
            "unique"     => false,
            "note"       => "",
            "sort_order"       => "100"


        ));

Дайте мне знать, если есть какой-либо ресурс/статья об этом.

Спасибо:)

Author: Dipesh Rangani, 2016-12-16

1 answers

Описание атрибута можно найти в модуле Magento\Eav:

app/code/Magento/Eav

Основной моделью для атрибута является Magento\Eav\Model\Attribute. Метод addAttribute определен в классе Magento\Eav\Setup\EavSetup. Все свойства были сопоставлены столбцам атрибутов eav в Magento\Catalog\Model\ResourceModel\Eav\Attribute\PropertyMapper:

/**
 * Map input attribute properties to storage representation
 *
 * @param array $input
 * @param int $entityTypeId
 * @return array
 * @SuppressWarnings(PHPMD.UnusedFormalParameter)
 */
public function map(array $input, $entityTypeId)
{
    return [
        'attribute_model' => $this->_getValue($input, 'attribute_model'),
        'backend_model' => $this->_getValue($input, 'backend'),
        'backend_type' => $this->_getValue($input, 'type', 'varchar'),
        'backend_table' => $this->_getValue($input, 'table'),
        'frontend_model' => $this->_getValue($input, 'frontend'),
        'frontend_input' => $this->_getValue($input, 'input', 'text'),
        'frontend_label' => $this->_getValue($input, 'label'),
        'frontend_class' => $this->_getValue($input, 'frontend_class'),
        'source_model' => $this->_getValue($input, 'source'),
        'is_required' => $this->_getValue($input, 'required', 1),
        'is_user_defined' => $this->_getValue($input, 'user_defined', 0),
        'default_value' => $this->_getValue($input, 'default'),
        'is_unique' => $this->_getValue($input, 'unique', 0),
        'note' => $this->_getValue($input, 'note'),
        'is_global' => $this->_getValue(
            $input,
            'global',
            \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_GLOBAL
        )
    ];
}

Я не могу ответить на все ваши вопросы, но я думаю, что эта информация поможет вам найти правильный путь.

 1
Author: Siarhey Uchukhlebau, 2016-12-16 07:05:46