ltsecurityinc安防产品在线商城代码
This commit is contained in:
+92
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
namespace Olegnax\Athlete2\Setup;
|
||||
|
||||
use Magento\Catalog\Model\Product;
|
||||
use Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface;
|
||||
use Magento\Framework\Setup\InstallDataInterface;
|
||||
use Magento\Framework\Setup\ModuleContextInterface;
|
||||
use Magento\Framework\Setup\ModuleDataSetupInterface;
|
||||
use Magento\Eav\Setup\EavSetup;
|
||||
use Magento\Eav\Setup\EavSetupFactory;
|
||||
|
||||
class InstallData implements InstallDataInterface {
|
||||
|
||||
private $eavSetupFactory;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param \Magento\Eav\Setup\EavSetupFactory $eavSetupFactory
|
||||
*/
|
||||
public function __construct(EavSetupFactory $eavSetupFactory) {
|
||||
$this->eavSetupFactory = $eavSetupFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function install(
|
||||
ModuleDataSetupInterface $setup, ModuleContextInterface $context
|
||||
) {
|
||||
$setup->startSetup();
|
||||
$this->_install($setup);
|
||||
$setup->endSetup();
|
||||
}
|
||||
|
||||
private function fields() {
|
||||
return [
|
||||
Product::ENTITY => [
|
||||
'ox_featured' => [
|
||||
'group' => 'Product Details',
|
||||
'type' => 'int',
|
||||
'backend' => '',
|
||||
'frontend' => '',
|
||||
'label' => 'Featured Product',
|
||||
'input' => 'boolean',
|
||||
'class' => '',
|
||||
'source' => 'Magento\Eav\Model\Entity\Attribute\Source\Boolean',
|
||||
'sort_order' => 3,
|
||||
'global' => ScopedAttributeInterface::SCOPE_GLOBAL,
|
||||
'visible' => true,
|
||||
'required' => false,
|
||||
'user_defined' => true,
|
||||
'default' => '0',
|
||||
'searchable' => false,
|
||||
'filterable' => false,
|
||||
'comparable' => false,
|
||||
'visible_on_front' => false,
|
||||
'used_in_product_listing' => true,
|
||||
'unique' => false,
|
||||
'apply_to' => ''
|
||||
],
|
||||
'img_hover' => [
|
||||
'group' => 'Image Management',
|
||||
'type' => 'varchar',
|
||||
'label' => 'Hover Image',
|
||||
'input' => 'media_image',
|
||||
'frontend' => 'Magento\Catalog\Model\Product\Attribute\Frontend\Image',
|
||||
'global' => ScopedAttributeInterface::SCOPE_STORE,
|
||||
'user_defined' => false,
|
||||
'filterable' => false,
|
||||
'visible_on_front' => false,
|
||||
'used_in_product_listing' => true,
|
||||
'sort_order' => 10,
|
||||
'required' => false
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
private function _install(ModuleDataSetupInterface $setup) {
|
||||
$eavSetup = $this->eavSetupFactory->create([
|
||||
'setup' => $setup]);
|
||||
$tablefields = $this->fields();
|
||||
foreach ($tablefields as $entity => $fields) {
|
||||
foreach ($fields as $key => $value) {
|
||||
$eavSetup->addAttribute($entity, $key, $value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+166
@@ -0,0 +1,166 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Olegnax
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Olegnax.com license that is
|
||||
* available through the world-wide-web at this URL:
|
||||
* https://www.olegnax.com/license
|
||||
*
|
||||
*
|
||||
* @category Olegnax
|
||||
* @package Olegnax_Athlete2
|
||||
* @copyright Copyright (c) 2023 Olegnax (http://www.olegnax.com/)
|
||||
*/
|
||||
|
||||
namespace Olegnax\Athlete2\Setup;
|
||||
|
||||
use Magento\Framework\DB\Ddl\Table;
|
||||
use Magento\Framework\Setup\InstallSchemaInterface;
|
||||
use Magento\Framework\Setup\ModuleContextInterface;
|
||||
use Magento\Framework\Setup\SchemaSetupInterface;
|
||||
use Magento\Framework\DB\Adapter\AdapterInterface;
|
||||
|
||||
class InstallSchema implements InstallSchemaInterface {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function install( SchemaSetupInterface $setup, ModuleContextInterface $context ) {
|
||||
$setup->startSetup();
|
||||
$this->_install( $setup );
|
||||
$setup->endSetup();
|
||||
}
|
||||
|
||||
public function installMagefanBlog( SchemaSetupInterface $setup ) {
|
||||
$installer = $setup;
|
||||
|
||||
// $installer->startSetup();
|
||||
|
||||
/**
|
||||
* Create table 'magefan_blog_post'
|
||||
*/
|
||||
$table = $installer->getConnection()->newTable(
|
||||
$installer->getTable('magefan_blog_post')
|
||||
)->addColumn(
|
||||
'post_id',
|
||||
\Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,
|
||||
null,
|
||||
['identity' => true, 'nullable' => false, 'primary' => true],
|
||||
'Post ID'
|
||||
)->addColumn(
|
||||
'title',
|
||||
\Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
|
||||
255,
|
||||
['nullable' => true],
|
||||
'Post Title'
|
||||
)->addColumn(
|
||||
'meta_keywords',
|
||||
\Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
|
||||
'64k',
|
||||
['nullable' => true],
|
||||
'Post Meta Keywords'
|
||||
)->addColumn(
|
||||
'meta_description',
|
||||
\Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
|
||||
'64k',
|
||||
['nullable' => true],
|
||||
'Post Meta Description'
|
||||
)->addColumn(
|
||||
'identifier',
|
||||
\Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
|
||||
100,
|
||||
['nullable' => true, 'default' => null],
|
||||
'Post String Identifier'
|
||||
)->addColumn(
|
||||
'content_heading',
|
||||
\Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
|
||||
255,
|
||||
['nullable' => true],
|
||||
'Post Content Heading'
|
||||
)->addColumn(
|
||||
'content',
|
||||
\Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
|
||||
'2M',
|
||||
[],
|
||||
'Post Content'
|
||||
)->addColumn(
|
||||
'creation_time',
|
||||
\Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP,
|
||||
null,
|
||||
[],
|
||||
'Post Creation Time'
|
||||
)->addColumn(
|
||||
'update_time',
|
||||
\Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP,
|
||||
null,
|
||||
[],
|
||||
'Post Modification Time'
|
||||
)->addColumn(
|
||||
'publish_time',
|
||||
\Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP,
|
||||
null,
|
||||
[],
|
||||
'Post Publish Time'
|
||||
)->addColumn(
|
||||
'is_active',
|
||||
\Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT,
|
||||
null,
|
||||
['nullable' => false, 'default' => '1'],
|
||||
'Is Post Active'
|
||||
)->addIndex(
|
||||
$installer->getIdxName('magefan_blog_post', ['identifier']),
|
||||
['identifier']
|
||||
)->addIndex(
|
||||
$setup->getIdxName(
|
||||
$installer->getTable('magefan_blog_post'),
|
||||
['title', 'meta_keywords', 'meta_description', 'identifier', 'content'],
|
||||
AdapterInterface::INDEX_TYPE_FULLTEXT
|
||||
),
|
||||
['title', 'meta_keywords', 'meta_description', 'identifier', 'content'],
|
||||
['type' => AdapterInterface::INDEX_TYPE_FULLTEXT]
|
||||
)->setComment(
|
||||
'Magefan Blog Post Table'
|
||||
);
|
||||
$installer->getConnection()->createTable($table);
|
||||
}
|
||||
|
||||
private function _install( SchemaSetupInterface $setup ) {
|
||||
$tables = [
|
||||
'magefan_blog_post' => [
|
||||
'ox_post_list_style' => [
|
||||
'type' => Table::TYPE_TEXT,
|
||||
'size' => 255,
|
||||
'nullable' => true,
|
||||
],
|
||||
],
|
||||
];
|
||||
$connection = $setup->getConnection();
|
||||
if ( !$setup->tableExists( 'magefan_blog_post' ) ) {
|
||||
$this->installMagefanBlog( $setup );
|
||||
}
|
||||
|
||||
foreach ( $tables as $table_name => $table ) {
|
||||
if ( !$setup->tableExists( $table_name ) ) {
|
||||
continue;
|
||||
}
|
||||
$_table = $setup->getTable( $table_name );
|
||||
foreach ( $table as $field_name => $field ) {
|
||||
foreach ( [
|
||||
'type' => Table::TYPE_INTEGER,
|
||||
'size' => null,
|
||||
'comment' => 'Added by plugin',
|
||||
] as $attr_name => $attr ) {
|
||||
if ( !array_key_exists( $attr_name, $field ) ) {
|
||||
$field[ $attr_name ] = $attr;
|
||||
}
|
||||
}
|
||||
|
||||
$connection->addColumn( $_table, $field_name, $field );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+279
@@ -0,0 +1,279 @@
|
||||
<?php
|
||||
/**
|
||||
* @author Olegnax
|
||||
* @package Olegnax_Athlete2
|
||||
* @copyright Copyright (c) 2023 Olegnax (http://olegnax.com/). All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Olegnax\Athlete2\Setup\Patch\Data;
|
||||
|
||||
use Magento\Catalog\Model\Product;
|
||||
use Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface;
|
||||
use Magento\Eav\Model\Entity\Attribute\Source\Boolean;
|
||||
use Magento\Eav\Setup\EavSetup;
|
||||
use Magento\Eav\Setup\EavSetupFactory;
|
||||
use Magento\Framework\Exception\LocalizedException;
|
||||
use Magento\Framework\Setup\ModuleDataSetupInterface;
|
||||
use Magento\Framework\Setup\Patch\DataPatchInterface;
|
||||
use Magento\Framework\Setup\Patch\PatchRevertableInterface;
|
||||
use Magento\Framework\Validator\ValidateException;
|
||||
|
||||
class AddOxGalleryVideoProductAttribute implements DataPatchInterface, PatchRevertableInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @var ModuleDataSetupInterface
|
||||
*/
|
||||
private $moduleDataSetup;
|
||||
/**
|
||||
* @var EavSetupFactory
|
||||
*/
|
||||
private $eavSetupFactory;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param ModuleDataSetupInterface $moduleDataSetup
|
||||
* @param EavSetupFactory $eavSetupFactory
|
||||
*/
|
||||
public function __construct(
|
||||
ModuleDataSetupInterface $moduleDataSetup,
|
||||
EavSetupFactory $eavSetupFactory
|
||||
) {
|
||||
$this->moduleDataSetup = $moduleDataSetup;
|
||||
$this->eavSetupFactory = $eavSetupFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function getDependencies()
|
||||
{
|
||||
return [
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \array[][]
|
||||
*/
|
||||
protected function getFields(){
|
||||
return [
|
||||
Product::ENTITY => [
|
||||
'ox_gallery_video' => [
|
||||
'apply_to' => '',
|
||||
'backend' => '',
|
||||
'comparable' => false,
|
||||
'default' => null,
|
||||
'filterable' => false,
|
||||
'frontend' => '',
|
||||
'global' => ScopedAttributeInterface::SCOPE_GLOBAL,
|
||||
'group' => 'Video',
|
||||
'input' => 'text',
|
||||
'is_filterable_in_grid' => false,
|
||||
'is_used_in_grid' => false,
|
||||
'is_visible_in_grid' => false,
|
||||
'label' => 'Video for Gallery',
|
||||
'description' => __('Add relative path to video file in media folder, without file type. Supported video formats: webm, mp4, ogg. Starting path is pub/media, so if your video placed in pub/media/video/yourvideo.mp4 then you should add following: video/yourvideo'),
|
||||
'option' => ['values' => [""]],
|
||||
'required' => false,
|
||||
'searchable' => false,
|
||||
'sort_order' => '10',
|
||||
'source' => '',
|
||||
'type' => 'varchar',
|
||||
'unique' => false,
|
||||
'used_in_product_listing' => false,
|
||||
'user_defined' => true,
|
||||
'visible' => true,
|
||||
'visible_on_front' => false,
|
||||
],
|
||||
'ox_gallery_video_index' => [
|
||||
'apply_to' => '',
|
||||
'backend' => '',
|
||||
'comparable' => false,
|
||||
'default' => 2,
|
||||
'description' => __('Video will replace existing image in defined position. Image will be used as fallback.'),
|
||||
'filterable' => false,
|
||||
'frontend' => '',
|
||||
'global' => ScopedAttributeInterface::SCOPE_GLOBAL,
|
||||
'group' => 'Video',
|
||||
'input' => 'text',
|
||||
'is_filterable_in_grid' => false,
|
||||
'is_used_in_grid' => false,
|
||||
'is_visible_in_grid' => false,
|
||||
'label' => 'Position in Gallery',
|
||||
'option' => ['values' => ["2"]],
|
||||
'required' => false,
|
||||
'searchable' => false,
|
||||
'sort_order' => '20',
|
||||
'source' => '',
|
||||
'type' => 'int',
|
||||
'unique' => false,
|
||||
'used_in_product_listing' => false,
|
||||
'user_defined' => true,
|
||||
'visible' => true,
|
||||
'visible_on_front' => false,
|
||||
],
|
||||
'ox_gallery_video_listing_hover' => [
|
||||
'apply_to' => '',
|
||||
'backend' => '',
|
||||
'comparable' => false,
|
||||
'default' => '0',
|
||||
'filterable' => false,
|
||||
'frontend' => '',
|
||||
'global' => ScopedAttributeInterface::SCOPE_GLOBAL,
|
||||
'group' => 'Video',
|
||||
'input' => 'boolean',
|
||||
'label' => 'Show on Hover in product Listing',
|
||||
'required' => false,
|
||||
'searchable' => false,
|
||||
'sort_order' => '30',
|
||||
'source' => Boolean::class,
|
||||
'type' => 'int',
|
||||
'unique' => false,
|
||||
'used_in_product_listing' => true,
|
||||
'user_defined' => true,
|
||||
'visible' => true,
|
||||
'visible_on_front' => false,
|
||||
],
|
||||
'ox_gallery_video_stop_on_click' => [
|
||||
'apply_to' => '',
|
||||
'backend' => '',
|
||||
'comparable' => false,
|
||||
'default' => '1',
|
||||
'filterable' => false,
|
||||
'frontend' => '',
|
||||
'global' => ScopedAttributeInterface::SCOPE_GLOBAL,
|
||||
'group' => 'Video',
|
||||
'input' => 'boolean',
|
||||
'label' => 'Stop Video on Click',
|
||||
'required' => false,
|
||||
'searchable' => false,
|
||||
'sort_order' => '40',
|
||||
'source' => Boolean::class,
|
||||
'type' => 'int',
|
||||
'unique' => false,
|
||||
'used_in_product_listing' => true,
|
||||
'user_defined' => true,
|
||||
'visible' => true,
|
||||
'visible_on_front' => false,
|
||||
'option' => ['values' => ["1"]],
|
||||
],
|
||||
'ox_gallery_video_autoplay' => [
|
||||
'apply_to' => '',
|
||||
'backend' => '',
|
||||
'comparable' => false,
|
||||
'default' => '1',
|
||||
'filterable' => false,
|
||||
'frontend' => '',
|
||||
'global' => ScopedAttributeInterface::SCOPE_GLOBAL,
|
||||
'group' => 'Video',
|
||||
'input' => 'boolean',
|
||||
'label' => 'Autoplay Video',
|
||||
'required' => false,
|
||||
'searchable' => false,
|
||||
'sort_order' => '50',
|
||||
'source' => Boolean::class,
|
||||
'type' => 'int',
|
||||
'unique' => false,
|
||||
'used_in_product_listing' => true,
|
||||
'user_defined' => true,
|
||||
'visible' => true,
|
||||
'visible_on_front' => false,
|
||||
'option' => ['values' => ["1"]],
|
||||
],
|
||||
'ox_gallery_video_loop' => [
|
||||
'apply_to' => '',
|
||||
'backend' => '',
|
||||
'comparable' => false,
|
||||
'default' => '1',
|
||||
'filterable' => false,
|
||||
'frontend' => '',
|
||||
'global' => ScopedAttributeInterface::SCOPE_GLOBAL,
|
||||
'group' => 'Video',
|
||||
'input' => 'boolean',
|
||||
'label' => 'Loop Video',
|
||||
'required' => false,
|
||||
'searchable' => false,
|
||||
'sort_order' => '60',
|
||||
'source' => Boolean::class,
|
||||
'type' => 'int',
|
||||
'unique' => false,
|
||||
'used_in_product_listing' => true,
|
||||
'user_defined' => true,
|
||||
'visible' => true,
|
||||
'visible_on_front' => false,
|
||||
'option' => ['values' => ["1"]],
|
||||
],
|
||||
'ox_gallery_video_controls' => [
|
||||
'apply_to' => '',
|
||||
'backend' => '',
|
||||
'comparable' => false,
|
||||
'default' => '0',
|
||||
'filterable' => false,
|
||||
'frontend' => '',
|
||||
'global' => ScopedAttributeInterface::SCOPE_GLOBAL,
|
||||
'group' => 'Video',
|
||||
'input' => 'boolean',
|
||||
'label' => 'Show Video Controls',
|
||||
'required' => false,
|
||||
'searchable' => false,
|
||||
'sort_order' => '70',
|
||||
'source' => Boolean::class,
|
||||
'type' => 'int',
|
||||
'unique' => false,
|
||||
'used_in_product_listing' => true,
|
||||
'user_defined' => true,
|
||||
'visible' => true,
|
||||
'visible_on_front' => false,
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
* @return AddOxGalleryVideoProductAttribute|void
|
||||
* @throws LocalizedException
|
||||
* @throws ValidateException
|
||||
*/
|
||||
public function apply()
|
||||
{
|
||||
$this->moduleDataSetup->getConnection()->startSetup();
|
||||
/** @var EavSetup $eavSetup */
|
||||
$eavSetup = $this->eavSetupFactory->create(['setup' => $this->moduleDataSetup]);
|
||||
|
||||
foreach ($this->getFields() as $entityTypeId => $fields) {
|
||||
foreach ($fields as $code => $attr) {
|
||||
$eavSetup->addAttribute($entityTypeId, $code, $attr);
|
||||
}
|
||||
}
|
||||
$this->moduleDataSetup->getConnection()->endSetup();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function revert()
|
||||
{
|
||||
$this->moduleDataSetup->getConnection()->startSetup();
|
||||
/** @var EavSetup $eavSetup */
|
||||
$eavSetup = $this->eavSetupFactory->create(['setup' => $this->moduleDataSetup]);
|
||||
foreach ($this->getFields() as $entityTypeId => $fields) {
|
||||
foreach ($fields as $code => $attr) {
|
||||
$eavSetup->removeAttribute($entityTypeId, $code, $attr);
|
||||
}
|
||||
}
|
||||
$this->moduleDataSetup->getConnection()->endSetup();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getAliases()
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
+207
@@ -0,0 +1,207 @@
|
||||
<?php
|
||||
/**
|
||||
* @author Olegnax
|
||||
* @package Olegnax_Athlete2
|
||||
* @copyright Copyright (c) 2023 Olegnax (http://olegnax.com/). All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
namespace Olegnax\Athlete2\Setup;
|
||||
|
||||
use Magento\Framework\DB\Adapter\AdapterInterface;
|
||||
use Magento\Framework\DB\Ddl\Table;
|
||||
use Magento\Framework\Setup\ModuleContextInterface;
|
||||
use Magento\Framework\Setup\SchemaSetupInterface;
|
||||
use Magento\Framework\Setup\UpgradeSchemaInterface;
|
||||
use Zend_Db_Exception;
|
||||
|
||||
class UpgradeSchema implements UpgradeSchemaInterface
|
||||
{
|
||||
/**
|
||||
* @param SchemaSetupInterface $setup
|
||||
* @param ModuleContextInterface $context
|
||||
*/
|
||||
public function upgrade(
|
||||
SchemaSetupInterface $setup,
|
||||
ModuleContextInterface $context
|
||||
) {
|
||||
$setup->startSetup();
|
||||
|
||||
$this->applyUpgradeFunctions($setup, $context);
|
||||
|
||||
$setup->endSetup();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SchemaSetupInterface $setup
|
||||
* @param ModuleContextInterface $context
|
||||
*/
|
||||
private function applyUpgradeFunctions(SchemaSetupInterface $setup, ModuleContextInterface $context)
|
||||
{
|
||||
$methods = $this->getUpgradeFunctions($context->getVersion());
|
||||
foreach ($methods as $method) {
|
||||
call_user_func_array([$this, $method], [$setup, $context]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $low_version
|
||||
* @return array
|
||||
*/
|
||||
private function getUpgradeFunctions($low_version = '1.0.0')
|
||||
{
|
||||
$methods = get_class_methods($this);
|
||||
foreach ($methods as $key => $method) {
|
||||
if (preg_match('/^upgrade_(.+)$/i', $method, $matches)) {
|
||||
if (version_compare($low_version, $matches[1], '<')) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
unset($methods[$key]);
|
||||
}
|
||||
|
||||
$methods = array_filter($methods);
|
||||
$methods = array_unique($methods);
|
||||
sort($methods);
|
||||
|
||||
return $methods;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SchemaSetupInterface $setup
|
||||
* @param ModuleContextInterface $context
|
||||
* @throws Zend_Db_Exception
|
||||
*/
|
||||
public function upgrade_99_0_1(SchemaSetupInterface $setup, ModuleContextInterface $context)
|
||||
{
|
||||
$tables = [
|
||||
'magefan_blog_post' => [
|
||||
'ox_post_list_style' => [
|
||||
'type' => Table::TYPE_TEXT,
|
||||
'size' => 255,
|
||||
'nullable' => true,
|
||||
],
|
||||
],
|
||||
];
|
||||
$connection = $setup->getConnection();
|
||||
if (!$setup->tableExists('magefan_blog_post')) {
|
||||
$this->installMagefanBlog($setup);
|
||||
}
|
||||
|
||||
foreach ($tables as $table_name => $table) {
|
||||
if (!$setup->tableExists($table_name)) {
|
||||
continue;
|
||||
}
|
||||
$_table = $setup->getTable($table_name);
|
||||
foreach ($table as $field_name => $field) {
|
||||
foreach ([
|
||||
'type' => Table::TYPE_INTEGER,
|
||||
'size' => null,
|
||||
'comment' => 'Added by plugin',
|
||||
] as $attr_name => $attr) {
|
||||
if (!array_key_exists($attr_name, $field)) {
|
||||
$field[$attr_name] = $attr;
|
||||
}
|
||||
}
|
||||
|
||||
$connection->addColumn($_table, $field_name, $field);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SchemaSetupInterface $setup
|
||||
* @throws Zend_Db_Exception
|
||||
*/
|
||||
public function installMagefanBlog(SchemaSetupInterface $setup)
|
||||
{
|
||||
$installer = $setup;
|
||||
|
||||
/**
|
||||
* Create table 'magefan_blog_post'
|
||||
*/
|
||||
$table = $installer->getConnection()->newTable(
|
||||
$installer->getTable('magefan_blog_post')
|
||||
)->addColumn(
|
||||
'post_id',
|
||||
Table::TYPE_INTEGER,
|
||||
null,
|
||||
['identity' => true, 'nullable' => false, 'primary' => true],
|
||||
'Post ID'
|
||||
)->addColumn(
|
||||
'title',
|
||||
Table::TYPE_TEXT,
|
||||
255,
|
||||
['nullable' => true],
|
||||
'Post Title'
|
||||
)->addColumn(
|
||||
'meta_keywords',
|
||||
Table::TYPE_TEXT,
|
||||
'64k',
|
||||
['nullable' => true],
|
||||
'Post Meta Keywords'
|
||||
)->addColumn(
|
||||
'meta_description',
|
||||
Table::TYPE_TEXT,
|
||||
'64k',
|
||||
['nullable' => true],
|
||||
'Post Meta Description'
|
||||
)->addColumn(
|
||||
'identifier',
|
||||
Table::TYPE_TEXT,
|
||||
100,
|
||||
['nullable' => true, 'default' => null],
|
||||
'Post String Identifier'
|
||||
)->addColumn(
|
||||
'content_heading',
|
||||
Table::TYPE_TEXT,
|
||||
255,
|
||||
['nullable' => true],
|
||||
'Post Content Heading'
|
||||
)->addColumn(
|
||||
'content',
|
||||
Table::TYPE_TEXT,
|
||||
'2M',
|
||||
[],
|
||||
'Post Content'
|
||||
)->addColumn(
|
||||
'creation_time',
|
||||
Table::TYPE_TIMESTAMP,
|
||||
null,
|
||||
[],
|
||||
'Post Creation Time'
|
||||
)->addColumn(
|
||||
'update_time',
|
||||
Table::TYPE_TIMESTAMP,
|
||||
null,
|
||||
[],
|
||||
'Post Modification Time'
|
||||
)->addColumn(
|
||||
'publish_time',
|
||||
Table::TYPE_TIMESTAMP,
|
||||
null,
|
||||
[],
|
||||
'Post Publish Time'
|
||||
)->addColumn(
|
||||
'is_active',
|
||||
Table::TYPE_SMALLINT,
|
||||
null,
|
||||
['nullable' => false, 'default' => '1'],
|
||||
'Is Post Active'
|
||||
)->addIndex(
|
||||
$installer->getIdxName('magefan_blog_post', ['identifier']),
|
||||
['identifier']
|
||||
)->addIndex(
|
||||
$setup->getIdxName(
|
||||
$installer->getTable('magefan_blog_post'),
|
||||
['title', 'meta_keywords', 'meta_description', 'identifier', 'content'],
|
||||
AdapterInterface::INDEX_TYPE_FULLTEXT
|
||||
),
|
||||
['title', 'meta_keywords', 'meta_description', 'identifier', 'content'],
|
||||
['type' => AdapterInterface::INDEX_TYPE_FULLTEXT]
|
||||
)->setComment(
|
||||
'Magefan Blog Post Table'
|
||||
);
|
||||
$installer->getConnection()->createTable($table);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user