@@ -37,6 +37,171 @@ public function install(
3737 SchemaSetupInterface $ setup ,
3838 ModuleContextInterface $ context
3939 ) {
40- //Your install script
40+ $ installer = $ setup ;
41+ $ installer ->startSetup ();
42+ //Create lof_producttags_tag table
43+ if (!$ installer ->tableExists ('lof_producttags_tag ' )) {
44+ $ table = $ installer ->getConnection ()->newTable (
45+ $ installer ->getTable ('lof_producttags_tag ' )
46+ )
47+ ->addColumn (
48+ 'tag_id ' ,
49+ \Magento \Framework \DB \Ddl \Table::TYPE_INTEGER ,
50+ null ,
51+ [
52+ 'identity ' => true ,
53+ 'unsigned ' => true ,
54+ 'nullable ' => false ,
55+ 'primary ' => true
56+ ],
57+ 'Tag ID '
58+ )
59+ ->addColumn (
60+ 'status ' ,
61+ \Magento \Framework \DB \Ddl \Table::TYPE_SMALLINT ,
62+ null ,
63+ ['nullable ' => false , 'default ' => '0 ' ],
64+ 'Status '
65+ )
66+ ->addColumn (
67+ 'tag_title ' ,
68+ \Magento \Framework \DB \Ddl \Table::TYPE_TEXT ,
69+ null ,
70+ ['nullable ' => false , 'default ' => '' ],
71+ 'Tag Title '
72+ )
73+ ->addColumn (
74+ 'identifier ' ,
75+ \Magento \Framework \DB \Ddl \Table::TYPE_TEXT ,
76+ null ,
77+ ['nullable ' => false , 'default ' => '' ],
78+ 'Identifier '
79+ )
80+ ->addColumn (
81+ 'customer_id ' ,
82+ \Magento \Framework \DB \Ddl \Table::TYPE_INTEGER ,
83+ null ,
84+ ['unsigned ' => true , 'nullable ' => false , 'default ' => '0 ' ],
85+ 'Customer Id '
86+ )
87+ ->addColumn (
88+ 'tag_description ' ,
89+ \Magento \Framework \DB \Ddl \Table::TYPE_TEXT ,
90+ '64k ' ,
91+ ['nullable ' => false , 'default ' => '' ],
92+ 'Tag Description '
93+ )
94+ ->addColumn (
95+ 'number_products ' ,
96+ \Magento \Framework \DB \Ddl \Table::TYPE_INTEGER ,
97+ null ,
98+ ['nullable ' => false , 'default ' => '0 ' ],
99+ 'Number of products for the tag '
100+ )
101+ ->addColumn (
102+ 'created_at ' ,
103+ \Magento \Framework \DB \Ddl \Table::TYPE_TIMESTAMP ,
104+ null ,
105+ ['nullable ' => false , 'default ' => \Magento \Framework \DB \Ddl \Table::TIMESTAMP_INIT ],
106+ 'Created At '
107+ )
108+ ->addColumn (
109+ 'modified_at ' ,
110+ \Magento \Framework \DB \Ddl \Table::TYPE_TIMESTAMP ,
111+ null ,
112+ ['nullable ' => false , 'default ' => \Magento \Framework \DB \Ddl \Table::TIMESTAMP_INIT ],
113+ 'Modified At '
114+ )
115+ ->setComment ('Product Tags Table ' )
116+ ->setOption ('type ' , 'InnoDB ' )
117+ ->setOption ('charset ' , 'utf8 ' );
118+ $ installer ->getConnection ()->createTable ($ table );
119+ $ installer ->getConnection ()->addIndex (
120+ $ installer ->getTable ('lof_producttags_tag ' ),
121+ $ setup ->getIdxName (
122+ $ installer ->getTable ('lof_producttags_tag ' ),
123+ ['tag_title ' ,'identifier ' ,'tag_description ' ],
124+ \Magento \Framework \DB \Adapter \AdapterInterface::INDEX_TYPE_FULLTEXT
125+ ),
126+ ['tag_title ' ,'identifier ' ,'tag_description ' ],
127+ \Magento \Framework \DB \Adapter \AdapterInterface::INDEX_TYPE_FULLTEXT
128+ );
129+ }
130+ //Create lof_producttags_product table
131+ if (!$ installer ->tableExists ('lof_producttags_product ' )) {
132+ $ table = $ installer ->getConnection ()->newTable (
133+ $ installer ->getTable ('lof_producttags_product ' )
134+ )
135+ ->addColumn (
136+ 'tag_id ' ,
137+ \Magento \Framework \DB \Ddl \Table::TYPE_INTEGER ,
138+ null ,
139+ [
140+ 'identity ' => false ,
141+ 'unsigned ' => true ,
142+ 'nullable ' => false ,
143+ 'foreign ' => true
144+ ],
145+ 'Tag ID '
146+ )
147+ ->addColumn (
148+ 'product_id ' ,
149+ \Magento \Framework \DB \Ddl \Table::TYPE_INTEGER ,
150+ null ,
151+ [
152+ 'identity ' => true ,
153+ 'unsigned ' => true ,
154+ 'nullable ' => false ,
155+ 'primary ' => true
156+ ],
157+ 'Product ID '
158+ )
159+ ->addColumn (
160+ 'position ' ,
161+ \Magento \Framework \DB \Ddl \Table::TYPE_INTEGER ,
162+ null ,
163+ ['nullable ' => false , 'default ' => '0 ' ],
164+ 'Position '
165+ )
166+ ->setComment ('products tags Table ' )
167+ ->setOption ('type ' , 'InnoDB ' )
168+ ->setOption ('charset ' , 'utf8 ' );
169+ $ installer ->getConnection ()->createTable ($ table );
170+ }
171+ //Create lof_producttags_store table
172+ if (!$ installer ->tableExists ('lof_producttags_store ' )) {
173+ $ table = $ installer ->getConnection ()->newTable (
174+ $ installer ->getTable ('lof_producttags_store ' )
175+ )
176+ ->addColumn (
177+ 'tag_id ' ,
178+ \Magento \Framework \DB \Ddl \Table::TYPE_INTEGER ,
179+ null ,
180+ [
181+ 'identity ' => false ,
182+ 'unsigned ' => true ,
183+ 'nullable ' => false ,
184+ 'foreign ' => true
185+ ],
186+ 'Tag ID '
187+ )
188+ ->addColumn (
189+ 'store_id ' ,
190+ \Magento \Framework \DB \Ddl \Table::TYPE_INTEGER ,
191+ null ,
192+ [
193+ 'identity ' => true ,
194+ 'unsigned ' => true ,
195+ 'nullable ' => false ,
196+ 'primary ' => true
197+ ],
198+ 'Store ID '
199+ )
200+ ->setComment ('Product Tags Store Table ' )
201+ ->setOption ('type ' , 'InnoDB ' )
202+ ->setOption ('charset ' , 'utf8 ' );
203+ $ installer ->getConnection ()->createTable ($ table );
204+ }
205+ $ installer ->endSetup ();
41206 }
42207}
0 commit comments