Files
esun3d/app/code/WeltPixel/LayeredNavigation/Setup/Patch/Schema/AddAttributeOptionsTable.php
T
2026-09-15 10:35:56 +08:00

126 lines
3.7 KiB
PHP
Executable File

<?php
namespace WeltPixel\LayeredNavigation\Setup\Patch\Schema;
use Magento\Framework\Setup\SchemaSetupInterface;
use Magento\Framework\Setup\Patch\SchemaPatchInterface;
use Magento\Framework\Setup\Patch\PatchVersionInterface;
class AddAttributeOptionsTable implements SchemaPatchInterface, PatchVersionInterface
{
/**
* @var SchemaSetupInterface $schemaSetup
*/
private $schemaSetup;
/**
* @param SchemaSetupInterface $schemaSetup
*/
public function __construct(SchemaSetupInterface $schemaSetup)
{
$this->schemaSetup = $schemaSetup;
}
/**
* {@inheritdoc}
*/
public function apply()
{
$setup = $this->schemaSetup;
$this->schemaSetup->startSetup();
/**
* Create table 'weltpixel_ln_attribute_options'
*/
$table = $setup->getConnection()->newTable(
$setup->getTable('weltpixel_ln_attribute_options')
)->addColumn(
'id',
\Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,
null,
['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true],
'Id'
)->addColumn(
'attribute_id',
\Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT,
null,
['unsigned' => true, 'nullable' => false, 'default' => '0'],
'Attribute Id'
)->addColumn(
'display_option',
\Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT,
null,
['unsigned' => true, 'nullable' => false, 'default' => '0'],
'Filter Display Option'
)->addColumn(
'visible_options',
\Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT,
null,
['unsigned' => true, 'nullable' => false, 'default' => '99'],
'Initial number of options'
)->addColumn(
'visible_options_step',
\Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT,
null,
['unsigned' => true, 'nullable' => false, 'default' => '99'],
'Expandable items behaviour'
)->addColumn(
'is_multiselect',
\Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT,
null,
['unsigned' => true, 'nullable' => false, 'default' => '0'],
'Enable Multiselect'
)->addColumn(
'show_quantity',
\Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT,
null,
['unsigned' => true, 'nullable' => false, 'default' => '0'],
'Show Quantity'
)->addColumn(
'sort_by',
\Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT,
null,
['unsigned' => true, 'nullable' => false, 'default' => '1'],
'Sort By'
)->addIndex(
$setup->getIdxName($setup->getTable('weltpixel_ln_attribute_options'),['id']),
['id']
)->addForeignKey(
$setup->getFkName('weltpixel_ln_attribute_options', 'attribute_id', 'eav_attribute', 'attribute_id'),
'attribute_id',
$setup->getTable('eav_attribute'),
'attribute_id',
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->setComment(
'WeltPixel Layered Navigation Attribute Options'
);
$setup->getConnection()->createTable($table);
$this->schemaSetup->endSetup();
}
/**
* {@inheritdoc}
*/
public static function getVersion()
{
return '1.0.0';
}
/**
* @inheritdoc
*/
public function getAliases()
{
return [];
}
/**
* @inheritdoc
*/
public static function getDependencies()
{
return [];
}
}