Skip to content

Commit 48783c0

Browse files
committed
resolved conflict files
1 parent 79b0e73 commit 48783c0

File tree

3 files changed

+48
-8
lines changed

3 files changed

+48
-8
lines changed

Model/ResourceModel/Tag.php

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,8 @@
2525

2626
class 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
}

Setup/InstallSchema.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff 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
)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
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>

0 commit comments

Comments
 (0)