Skip to content

Commit 788db62

Browse files
authored
Merge pull request #6 from landofcoder/develop
Develop
2 parents 4204d83 + cf09e13 commit 788db62

File tree

9 files changed

+248
-32
lines changed

9 files changed

+248
-32
lines changed

Controller/Tag/Index.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
namespace Lof\ProductTags\Controller\Adminhtml\Tag;
4+
5+
class Index extends \Magento\Backend\App\Action
6+
{
7+
protected $resultPageFactory = false;
8+
9+
public function __construct(
10+
\Magento\Backend\App\Action\Context $context,
11+
\Magento\Framework\View\Result\PageFactory $resultPageFactory
12+
)
13+
{
14+
parent::__construct($context);
15+
$this->resultPageFactory = $resultPageFactory;
16+
}
17+
18+
public function execute()
19+
{
20+
$resultPage = $this->resultPageFactory->create();
21+
$resultPage->getConfig()->getTitle()->prepend((__('Posts')));
22+
23+
return $resultPage;
24+
}
25+
26+
27+
}

Helper/Data.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class Data extends AbstractHelper
3636
*/
3737

3838
protected $scopeConfig;
39-
const XML_PATH_HELLOWORLD = 'lofproductags/';
39+
const XML_PATH_TAG = 'lofproductags/';
4040
public function __construct(Context $context,ScopeConfigInterface $scopeConfig)
4141
{
4242
parent::__construct($context);
@@ -54,6 +54,6 @@ public function getConfigValue($field, $storeId = null)
5454
}
5555
public function getGeneralConfig($code, $storeId = null)
5656
{
57-
return $this->getConfigValue(self::XML_PATH_HELLOWORLD .'general/'. $code, $storeId);
57+
return $this->getConfigValue(self::XML_PATH_TAG .'general/'. $code, $storeId);
5858
}
5959
}

Setup/InstallSchema.php

Lines changed: 166 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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
}

Setup/UpgradeSchema.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ public function upgrade(
3737
SchemaSetupInterface $setup,
3838
ModuleContextInterface $context
3939
) {
40-
if (version_compare($context->getVersion(), "1.0.0", "<")) {
41-
//Your upgrade script
42-
}
40+
$installer = $setup;
41+
42+
$installer->endSetup();
4343
}
4444
}

etc/adminhtml/menu.xml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
<?xml version="1.0" ?>
22
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Backend:etc/menu.xsd">
33
<menu>
4-
<add id="Lof::top_level" module="Lof_ProductTags" resource="Magento_Backend::content" sortOrder="9999" title="Lof"/>
5-
<add action="lofproducttags/tags/index" id="Lof_ProductTags::tags_index" module="Lof_ProductTags" parent="Lof::top_level" resource="Lof_ProductTags::tags_index" sortOrder="9999" title="tags index"/>
6-
<add action="lof_producttags/tag/index" id="Lof_ProductTags::lof_producttags_tag" module="Lof_ProductTags" parent="Lof::top_level" resource="Magento_Backend::content" sortOrder="9999" title="Tag"/>
4+
<add id="Lof_ProductTags::producttags" module="Lof_ProductTags" parent="Magento_Catalog::inventory" resource="Lof_ProductTags::lofproducttags" action="lofproducttags/tag/index" sortOrder="9999" title="Product Tags"/>
75
</menu>
86
</config>

etc/adminhtml/routes.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,5 @@
44
<route frontName="lofproducttags" id="lofproducttags">
55
<module before="Magento_Backend" name="Lof_ProductTags"/>
66
</route>
7-
<route frontName="lof_producttags" id="lof_producttags">
8-
<module before="Magento_Backend" name="Lof_ProductTags"/>
9-
</route>
107
</router>
118
</config>

etc/adminhtml/system.xml

Lines changed: 41 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,32 +10,64 @@
1010
<resource>Lof_ProductTags::config_lof_producttags</resource>
1111
<group id="general" showInDefault="1" showInStore="1" showInWebsite="1" sortOrder="10" translate="label">
1212
<label>general</label>
13-
<field id="enable" translate="label" type="select" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">
13+
<field id="enabled" translate="label" type="select" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">
1414
<label>Enable</label>
1515
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
1616
</field>
1717
<field id="route" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">
1818
<label>Route</label>
1919
<comment>This text will change your url.</comment>
2020
<depends>
21-
<field id = "enable">1</field>
21+
<field id ="enabled">1</field>
2222
</depends>
2323
</field>
24-
<field id="enable_tag_block" translate="label" type="select" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">
25-
<label>Enable tag block</label>
24+
<field id="enable_tag_on_product" translate="label" type="select" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">
25+
<label>Enable tags block</label>
2626
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
27+
<comment>show/hide product tags on product detail page.</comment>
2728
<depends>
28-
<field id = "enable">1</field>
29+
<field id ="enabled">1</field>
2930
</depends>
3031
</field>
31-
<field id="number_tag" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">
32-
<label>Number tag display</label>
33-
<comment>The number of tags can be displayed on product detail page.</comment>
32+
<field id="product_tag_title" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">
33+
<label>Product Tags Block Title</label>
3434
<depends>
35-
<field id = "enable">1</field>
35+
<field id ="enabled">1</field>
36+
<field id ="enable_tag_on_product">1</field>
37+
</depends>
38+
</field>
39+
<field id="number_tags" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">
40+
<label>Limit tags to show</label>
41+
<depends>
42+
<field id ="enabled">1</field>
43+
<field id ="enable_tag_on_product">1</field>
44+
</depends>
45+
</field>
46+
47+
<field id="enable_tag_sidebar" translate="label" type="select" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">
48+
<label>Enable tag block on sidebar</label>
49+
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
50+
<comment>show/hide product tags on sidebar position.</comment>
51+
<depends>
52+
<field id ="enabled">1</field>
53+
</depends>
54+
</field>
55+
<field id="tag_sidebar_title" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">
56+
<label>Sidebar Tags Block Title</label>
57+
<depends>
58+
<field id ="enabled">1</field>
59+
<field id ="enable_tag_sidebar">1</field>
60+
</depends>
61+
</field>
62+
<field id="number_tags_sidebar" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">
63+
<label>Limit tags to show on sidebar</label>
64+
<depends>
65+
<field id ="enabled">1</field>
66+
<field id ="enable_tag_sidebar">1</field>
3667
</depends>
3768
</field>
3869
</group>
70+
<!-- <resource>Lof_ProductTags::lof_producttags</resource> -->
3971
</section>
4072
</system>
4173
</config>

etc/config.xml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,14 @@
33
<default>
44
<lofproductags>
55
<general>
6-
<enabled/>
6+
<enabled>1</enabled>
7+
<route>tags</route>
8+
<enable_tag_on_product>1</enable_tag_on_product>
9+
<product_tag_title>Trending</product_tag_title>
10+
<number_tags>10</number_tags>
11+
<enable_tag_sidebar>1</enable_tag_sidebar>
12+
<tag_sidebar_title>Product Tags</tag_sidebar_title>
13+
<number_tags_sidebar>20</number_tags_sidebar>
714
</general>
815
</lofproductags>
916
</default>

etc/db_schema.xml

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)