File tree Expand file tree Collapse file tree 3 files changed +48
-8
lines changed
view/frontend/templates/tag/product Expand file tree Collapse file tree 3 files changed +48
-8
lines changed Original file line number Diff line number Diff line change 2525
2626class Tag extends \Magento \Framework \Model \ResourceModel \Db \AbstractDb
2727{
28- public function __construct (
29- \Magento \Framework \Model \ResourceModel \Db \Context $ context
30- )
31- {
32- parent ::__construct ($ context );
33- }
28+
29+ protected $ _tagProductTable ;
3430 /**
3531 * Define resource model
3632 *
@@ -40,4 +36,35 @@ protected function _construct()
4036 {
4137 $ this ->_init ('lof_producttags_tag ' , 'tag_id ' );
4238 }
39+ /**
40+ * Category product table name getter
41+ *
42+ * @return string
43+ */
44+ public function getTagProductTable ()
45+ {
46+ if (!$ this ->_tagProductTable ) {
47+ $ this ->_tagProductTable = $ this ->getTable ('lof_producttags_product ' );
48+ }
49+ return $ this ->_tagProductTable ;
50+ }
51+ /**
52+ * Get positions of associated to category products
53+ *
54+ * @param \Lof\ProductTags\Model\Tag $tag
55+ * @return array
56+ */
57+ public function getProductsPosition ($ tag )
58+ {
59+ $ select = $ this ->getConnection ()->select ()->from (
60+ $ this ->getTagProductTable (),
61+ ['product_id ' , 'position ' ]
62+ )->where (
63+ "{$ this ->getTable ('lof_producttags_product ' )}.tag_id = ? " ,
64+ $ tag ->getId ()
65+ );
66+ $ bind = ['tag_id ' => (int )$ tag ->getId ()];
67+
68+ return $ this ->getConnection ()->fetchPairs ($ select , $ bind );
69+ }
4370}
Original file line number Diff line number Diff line change @@ -178,8 +178,10 @@ public function install(
178178 \Magento \Framework \DB \Ddl \Table::TYPE_INTEGER ,
179179 null ,
180180 [
181+ 'identity ' => false ,
181182 'unsigned ' => true ,
182- 'nullable ' => false
183+ 'nullable ' => false ,
184+ 'foreign ' => true
183185 ],
184186 'Tag ID '
185187 )
@@ -188,8 +190,10 @@ public function install(
188190 \Magento \Framework \DB \Ddl \Table::TYPE_INTEGER ,
189191 null ,
190192 [
193+ 'identity ' => true ,
191194 'unsigned ' => true ,
192- 'nullable ' => false
195+ 'nullable ' => false ,
196+ 'primary ' => true
193197 ],
194198 'Store ID '
195199 )
Original file line number Diff line number Diff line change 1+ <?php
2+ /**
3+ * @var $block \Lof\ProductTags\Block\Tag\Product\ListProduct
4+ */
5+ ?>
6+ <div>
7+ <?= $ block ->getListProducts () ?>
8+ <?= __ ('Hello Lof_ProductTags::tag/product/listproduct.phtml ' ) ?>
9+ </div>
You can’t perform that action at this time.
0 commit comments