| Current Path : /var/www/html/app/code/FlipsDigital/TextbookListBook/Setup/ |
| Current File : /var/www/html/app/code/FlipsDigital/TextbookListBook/Setup/TextbookListBookSetup.php |
<?php
/**
* TextbookListBookSetup
*
* @copyright Copyright © 2021 FlipsDigital. All rights reserved.
* @author calvin.so@flipsdigital.com
*/
namespace FlipsDigital\TextbookListBook\Setup;
use Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface;
use Magento\Eav\Setup\EavSetup;
use Magento\Catalog\Model\Product\Attribute\Backend\Price;
/**
* @codeCoverageIgnore
*/
class TextbookListBookSetup extends EavSetup
{
/**
* Entity type for TextbookListBook EAV attributes
*/
const ENTITY_TYPE_CODE = 'flipsdigital_textbooklistbook';
/**
* Retrieve Entity Attributes
*
* @return array
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
protected function getAttributes()
{
$attributes = [];
$attributes['identifier'] = [
'type' => 'static',
'label' => 'identifier',
'input' => 'text',
'required' => true,
'sort_order' => 10,
'global' => ScopedAttributeInterface::SCOPE_GLOBAL,
'group' => 'General',
'validate_rules' => 'a:2:{s:15:"max_text_length";i:100;s:15:"min_text_length";i:1;}'
];
$sort_order = 10;
$attributes['mers_stock_source_table'] = [
'type' => 'varchar',
'label' => 'MersStock - Source Table',
'input' => 'text',
'required' => true,
'sort_order' => $sort_order++,
'global' => ScopedAttributeInterface::SCOPE_STORE,
'group' => 'General',
];
$attributes['mers_stock_source_g_gl_group_booklist_id'] = [
'type' => 'int',
'label' => 'MersStock - Source [G_GL_GROUP_BOOKLIST].[ID]',
'input' => 'text',
'required' => true,
'sort_order' => $sort_order++,
'global' => ScopedAttributeInterface::SCOPE_STORE,
'group' => 'General',
];
$attributes['mers_stock_source_g_gl_id'] = [
'type' => 'int',
'label' => 'MersStock - Source [G_GL].[ID]',
'input' => 'text',
'required' => true,
'sort_order' => $sort_order++,
'global' => ScopedAttributeInterface::SCOPE_STORE,
'group' => 'General',
];
$attributes['mers_stock_source_g_gl_group_id'] = [
'type' => 'int',
'label' => 'MersStock - Source [G_GL_GROUP].[ID]',
'input' => 'text',
'required' => true,
'sort_order' => $sort_order++,
'global' => ScopedAttributeInterface::SCOPE_STORE,
'group' => 'General',
];
$attributes['mers_stock_source_s_product_code'] = [
'type' => 'varchar',
'label' => 'MersStock - Source [S_PRODUCT].[CODE]',
'input' => 'text',
'required' => true,
'sort_order' => $sort_order++,
'global' => ScopedAttributeInterface::SCOPE_STORE,
'group' => 'General',
];
$attributes['product_id'] = [
'type' => 'int',
'label' => 'Product Id',
'input' => 'text',
'required' => true,
'sort_order' => $sort_order++,
'global' => ScopedAttributeInterface::SCOPE_STORE,
'group' => 'General',
];
$attributes['booklist_id'] = [
'type' => 'int',
'label' => 'Book List Id',
'input' => 'text',
'required' => true,
'sort_order' => $sort_order++,
'global' => ScopedAttributeInterface::SCOPE_STORE,
'group' => 'General',
];
$attributes['name'] = [
'type' => 'varchar',
'label' => 'Name',
'input' => 'text',
'required' => true,
'sort_order' => $sort_order++,
'global' => ScopedAttributeInterface::SCOPE_STORE,
'group' => 'General',
];
$attributes['publisher'] = [
'type' => 'varchar',
'label' => 'Publisher',
'input' => 'text',
'required' => true,
'sort_order' => $sort_order++,
'global' => ScopedAttributeInterface::SCOPE_STORE,
'group' => 'General',
];
$attributes['print_section'] = [
'type' => 'varchar',
'label' => 'Print Section',
'input' => 'text',
'required' => true,
'sort_order' => $sort_order++,
'global' => ScopedAttributeInterface::SCOPE_STORE,
'group' => 'General',
];
$attributes['print_seq'] = [
'type' => 'int',
'label' => 'Print Seq',
'input' => 'text',
'required' => true,
'sort_order' => $sort_order++,
'global' => ScopedAttributeInterface::SCOPE_STORE,
'group' => 'General',
];
$attributes['price_original'] = [
'type' => 'decimal',
'length' => '10,2',
'label' => 'Price Original',
'input' => 'price',
'backend' => Price::class,
'searchable' => true,
'visible_in_advanced_search' => true,
'used_in_product_listing' => true,
'used_for_sort_by' => true,
'required' => true,
'sort_order' => $sort_order++,
'global' => ScopedAttributeInterface::SCOPE_STORE,
'group' => 'General',
];
$attributes['price_selling'] = [
'type' => 'decimal',
'length' => '10,2',
'label' => 'Price Selling',
'input' => 'price',
'backend' => Price::class,
'searchable' => true,
'visible_in_advanced_search' => true,
'used_in_product_listing' => true,
'used_for_sort_by' => true,
'required' => true,
'sort_order' => $sort_order++,
'global' => ScopedAttributeInterface::SCOPE_STORE,
'group' => 'General',
];
$attributes['price_not_buy_all'] = [
'type' => 'decimal',
'length' => '10,2',
'label' => 'Price Not Buy All',
'input' => 'price',
'backend' => Price::class,
'searchable' => true,
'visible_in_advanced_search' => true,
'used_in_product_listing' => true,
'used_for_sort_by' => true,
'required' => true,
'sort_order' => $sort_order++,
'global' => ScopedAttributeInterface::SCOPE_STORE,
'group' => 'General',
];
$attributes['must_buy'] = [
'type' => 'int',
'label' => 'Status',
'input' => 'select',
'source' => 'Magento\Eav\Model\Entity\Attribute\Source\Boolean',
'sort_order' => $sort_order++,
'global' => ScopedAttributeInterface::SCOPE_STORE,
'group' => 'General',
];
$attributes['magento_hidden'] = [
'type' => 'int',
'label' => 'Magento Hidden',
'input' => 'select',
'source' => 'Magento\Eav\Model\Entity\Attribute\Source\Boolean',
'sort_order' => $sort_order++,
'global' => ScopedAttributeInterface::SCOPE_STORE,
'group' => 'General',
];
$attributes['buy_default'] = [
'type' => 'int',
'label' => 'Magento Buy Default',
'input' => 'select',
'source' => 'Magento\Eav\Model\Entity\Attribute\Source\Boolean',
'sort_order' => $sort_order++,
'global' => ScopedAttributeInterface::SCOPE_STORE,
'group' => 'General',
];
$attributes['must_buy_tgt'] = [
'type' => 'text',
'label' => 'Must Buy Together',
'input' => 'text',
'sort_order' => $sort_order++,
'global' => ScopedAttributeInterface::SCOPE_STORE,
'group' => 'General',
];
$attributes['cannot_buy_tgt'] = [
'type' => 'text',
'label' => 'Cannot Buy Together',
'input' => 'text',
'sort_order' => $sort_order++,
'global' => ScopedAttributeInterface::SCOPE_STORE,
'group' => 'General',
];
$attributes['buy_at_least_one'] = [
'type' => 'text',
'label' => 'Buy At Least One',
'input' => 'text',
'sort_order' => $sort_order++,
'global' => ScopedAttributeInterface::SCOPE_STORE,
'group' => 'General',
];
$attributes['GroupItemDisplayName'] = [
'type' => 'text',
'label' => 'GroupItemDisplayName',
'input' => 'text',
'sort_order' => $sort_order++,
'global' => ScopedAttributeInterface::SCOPE_STORE,
'group' => 'General',
];
$attributes['GroupItemDisplayPublisher'] = [
'type' => 'text',
'label' => 'GroupItemDisplayPublisher',
'input' => 'text',
'sort_order' => $sort_order++,
'global' => ScopedAttributeInterface::SCOPE_STORE,
'group' => 'General',
];
$attributes['GroupNameEng'] = [
'type' => 'text',
'label' => 'GroupNameEng',
'input' => 'text',
'sort_order' => $sort_order++,
'global' => ScopedAttributeInterface::SCOPE_STORE,
'group' => 'General',
];
$attributes['GroupNameChi'] = [
'type' => 'text',
'label' => 'GroupNameChi',
'input' => 'text',
'sort_order' => $sort_order++,
'global' => ScopedAttributeInterface::SCOPE_STORE,
'group' => 'General',
];
$attributes['status'] = [
'type' => 'int',
'label' => 'Status',
'input' => 'select',
'source' => 'Magento\Eav\Model\Entity\Attribute\Source\Boolean',
'sort_order' => $sort_order++,
'global' => ScopedAttributeInterface::SCOPE_STORE,
'group' => 'General',
];
return $attributes;
}
/**
* Retrieve default entities: textbooklistbook
*
* @return array
*/
public function getDefaultEntities()
{
$entities = [
self::ENTITY_TYPE_CODE => [
'entity_model' => 'FlipsDigital\TextbookListBook\Model\ResourceModel\TextbookListBook',
'attribute_model' => 'FlipsDigital\TextbookListBook\Model\ResourceModel\Eav\Attribute',
'table' => self::ENTITY_TYPE_CODE . '_entity',
'increment_model' => null,
'additional_attribute_table' => self::ENTITY_TYPE_CODE . '_eav_attribute',
'entity_attribute_collection' => 'FlipsDigital\TextbookListBook\Model\ResourceModel\Attribute\Collection',
'attributes' => $this->getAttributes()
]
];
return $entities;
}
}