Skip to content

Commit 04ffbc9

Browse files
committed
Fix wrong query & change plugin version
1 parent 72733c3 commit 04ffbc9

5 files changed

+50
-5
lines changed

Config/module.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<descriptive locale="en_US">
88
<title>Keyword</title>
99
</descriptive>
10-
<version>2.1.0</version>
10+
<version>2.2.0</version>
1111
<author>
1212
<name>Michaël Espeche</name>
1313
<email>mespeche@openstudio.fr</email>

Loop/KeywordCategory.php

+12-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
use Keyword\Model\Map\CategoryAssociatedKeywordTableMap;
2828
use Propel\Runtime\ActiveQuery\Criteria;
2929
use Propel\Runtime\ActiveQuery\Join;
30+
use Propel\Runtime\Collection\ObjectCollection;
3031
use Thelia\Core\Template\Element\LoopResultRow;
3132
use Thelia\Core\Template\Loop\Argument\Argument;
3233
use Thelia\Core\Template\Loop\Category;
@@ -81,6 +82,8 @@ public function buildModelCriteria()
8182
$search = parent::buildModelCriteria();
8283

8384
$keyword = KeywordQuery::create();
85+
86+
/** @var ObjectCollection $results */
8487
$results = $keyword
8588
->findByCode($this->getKeyword())
8689
;
@@ -91,6 +94,14 @@ public function buildModelCriteria()
9194
}
9295

9396
$categoryIds = array();
97+
$keywordListId = array();
98+
$keywordIds = $results->getData();
99+
100+
foreach ($keywordIds as $keyword) {
101+
$keywordListId[] = $keyword->getId();
102+
}
103+
104+
$keywordListId = implode(',', $keywordListId);
94105

95106
foreach ($results as $result) {
96107
// If any product is associated with keyword
@@ -110,7 +121,7 @@ public function buildModelCriteria()
110121
$join->setJoinType(Criteria::INNER_JOIN);
111122

112123
$search->addJoinObject($join, 'category_associated_keyword_join');
113-
124+
$search->addJoinCondition('category_associated_keyword_join','category_associated_keyword.keyword_id IN ('.$keywordListId.')');
114125
$search->addJoinCondition('category_associated_keyword_join','category_associated_keyword.category_id IN ('.$categoryIds.')');
115126
$search->withColumn('category_associated_keyword.position', 'category_position');
116127

Loop/KeywordContent.php

+12-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
use Keyword\Model\Map\ContentAssociatedKeywordTableMap;
2828
use Propel\Runtime\ActiveQuery\Criteria;
2929
use Propel\Runtime\ActiveQuery\Join;
30+
use Propel\Runtime\Collection\ObjectCollection;
3031
use Thelia\Core\Template\Element\LoopResultRow;
3132
use Thelia\Core\Template\Loop\Argument\Argument;
3233
use Thelia\Core\Template\Loop\Content;
@@ -80,6 +81,8 @@ public function buildModelCriteria()
8081
$search = parent::buildModelCriteria();
8182

8283
$keyword = KeywordQuery::create();
84+
85+
/** @var ObjectCollection $results */
8386
$results = $keyword
8487
->findByCode($this->getKeyword())
8588
;
@@ -90,6 +93,14 @@ public function buildModelCriteria()
9093
}
9194

9295
$contentIds = array();
96+
$keywordListId = array();
97+
$keywordIds = $results->getData();
98+
99+
foreach ($keywordIds as $keyword) {
100+
$keywordListId[] = $keyword->getId();
101+
}
102+
103+
$keywordListId = implode(',', $keywordListId);
93104

94105
foreach ($results as $result) {
95106
// If any content is associated with keyword
@@ -109,7 +120,7 @@ public function buildModelCriteria()
109120
$join->setJoinType(Criteria::INNER_JOIN);
110121

111122
$search->addJoinObject($join, 'content_associated_keyword_join');
112-
123+
$search->addJoinCondition('content_associated_keyword_join','content_associated_keyword.keyword_id IN ('.$keywordListId.')');
113124
$search->addJoinCondition('content_associated_keyword_join','content_associated_keyword.content_id IN ('.$contentIds.')');
114125
$search->withColumn('content_associated_keyword.position', 'content_position');
115126

Loop/KeywordFolder.php

+13-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
use Keyword\Model\Map\FolderAssociatedKeywordTableMap;
2828
use Propel\Runtime\ActiveQuery\Criteria;
2929
use Propel\Runtime\ActiveQuery\Join;
30+
use Propel\Runtime\Collection\ObjectCollection;
3031
use Thelia\Core\Template\Element\LoopResultRow;
3132
use Thelia\Core\Template\Loop\Argument\Argument;
3233
use Thelia\Core\Template\Loop\Folder;
@@ -80,6 +81,8 @@ public function buildModelCriteria()
8081
$search = parent::buildModelCriteria();
8182

8283
$keyword = KeywordQuery::create();
84+
85+
/** @var ObjectCollection $results */
8386
$results = $keyword
8487
->findByCode($this->getKeyword())
8588
;
@@ -90,8 +93,17 @@ public function buildModelCriteria()
9093
}
9194

9295
$folderIds = array();
96+
$keywordListId = array();
97+
$keywordIds = $results->getData();
98+
99+
foreach ($keywordIds as $keyword) {
100+
$keywordListId[] = $keyword->getId();
101+
}
102+
103+
$keywordListId = implode(',', $keywordListId);
93104

94105
foreach ($results as $result) {
106+
95107
// If any content is associated with keyword
96108
if (true === $result->getFolders()->isEmpty()) {
97109
return null;
@@ -109,7 +121,7 @@ public function buildModelCriteria()
109121
$join->setJoinType(Criteria::INNER_JOIN);
110122

111123
$search->addJoinObject($join, 'folder_associated_keyword_join');
112-
124+
$search->addJoinCondition('folder_associated_keyword_join','folder_associated_keyword.keyword_id IN ('.$keywordListId.')');
113125
$search->addJoinCondition('folder_associated_keyword_join','folder_associated_keyword.folder_id IN ('.$folderIds.')');
114126
$search->withColumn('folder_associated_keyword.position', 'folder_position');
115127

Loop/KeywordProduct.php

+12-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
use Keyword\Model\Map\ProductAssociatedKeywordTableMap;
2828
use Propel\Runtime\ActiveQuery\Criteria;
2929
use Propel\Runtime\ActiveQuery\Join;
30+
use Propel\Runtime\Collection\ObjectCollection;
3031
use Thelia\Core\Template\Element\LoopResultRow;
3132
use Thelia\Core\Template\Loop\Argument\Argument;
3233
use Thelia\Core\Template\Loop\Product;
@@ -82,6 +83,8 @@ public function buildModelCriteria()
8283
$search = parent::buildModelCriteria();
8384

8485
$keyword = KeywordQuery::create();
86+
87+
/** @var ObjectCollection $results */
8588
$results = $keyword
8689
->findByCode($this->getKeyword())
8790
;
@@ -92,6 +95,14 @@ public function buildModelCriteria()
9295
}
9396

9497
$productIds = array();
98+
$keywordListId = array();
99+
$keywordIds = $results->getData();
100+
101+
foreach ($keywordIds as $keyword) {
102+
$keywordListId[] = $keyword->getId();
103+
}
104+
105+
$keywordListId = implode(',', $keywordListId);
95106

96107
foreach ($results as $result) {
97108
// If any content is associated with keyword
@@ -111,7 +122,7 @@ public function buildModelCriteria()
111122
$join->setJoinType(Criteria::INNER_JOIN);
112123

113124
$search->addJoinObject($join, 'product_associated_keyword_join');
114-
125+
$search->addJoinCondition('category_associated_keyword_join','category_associated_keyword.keyword_id IN ('.$keywordListId.')');
115126
$search->addJoinCondition('product_associated_keyword_join','product_associated_keyword.product_id IN ('.$productIds.')');
116127
$search->withColumn('product_associated_keyword.position', 'product_position');
117128

0 commit comments

Comments
 (0)