@@ -51,6 +51,8 @@ class DefaultMysql implements ProductListInterface
5151
5252 protected LoggerInterface $ logger ;
5353
54+ private const AND = ' AND ' ;
55+
5456 public function __construct (MysqlConfigInterface $ tenantConfig , LoggerInterface $ pimcoreEcommerceSqlLogger )
5557 {
5658 $ this ->tenantName = $ tenantConfig ->getTenantName ();
@@ -100,9 +102,10 @@ public function resetCondition(string $fieldname): void
100102 public function addRelationCondition (string $ fieldname , string |array $ condition ): void
101103 {
102104 $ realFieldname = $ this ->getRealFieldname ($ fieldname );
105+ $ fieldnameCondition = '`fieldname` = ' . $ this ->quote ($ realFieldname );
103106
104107 $ this ->products = null ;
105- $ this ->relationConditions [$ fieldname ][] = ' `fieldname` = ' . $ this -> quote ( $ realFieldname ) . ' AND ' . $ condition ;
108+ $ this ->relationConditions [$ fieldname ][] = $ fieldnameCondition . self :: AND . $ condition ;
106109 }
107110
108111 /**
@@ -470,18 +473,18 @@ protected function buildQueryFromConditions(bool $excludeConditions = false, ?st
470473 $ variantMode = $ this ->getVariantMode ();
471474 }
472475
473- $ preCondition = 'active = 1 AND virtualProductActive = 1 ' ;
476+ $ preCondition = 'active = 1 ' . self :: AND . ' virtualProductActive = 1 ' ;
474477 if ($ this ->inProductList ) {
475- $ preCondition .= ' AND inProductList = 1 ' ;
478+ $ preCondition .= self :: AND . ' inProductList = 1 ' ;
476479 }
477480
478481 $ tenantCondition = $ this ->getCurrentTenantConfig ()->getCondition ();
479482 if ($ tenantCondition ) {
480- $ preCondition .= ' AND ' . $ tenantCondition ;
483+ $ preCondition .= self :: AND . $ tenantCondition ;
481484 }
482485
483486 if ($ this ->getCategory ()) {
484- $ preCondition .= " AND parentCategoryIds LIKE '%, " . $ this ->getCategory ()->getId () . ",%' " ;
487+ $ preCondition .= self :: AND . " parentCategoryIds LIKE '%, " . $ this ->getCategory ()->getId () . ",%' " ;
485488 }
486489
487490 $ condition = $ preCondition ;
@@ -492,27 +495,27 @@ protected function buildQueryFromConditions(bool $excludeConditions = false, ?st
492495 case ProductListInterface::VARIANT_MODE_INCLUDE_PARENT_OBJECT :
493496
494497 //make sure, that only variant objects are considered
495- $ condition .= ' AND a.id != virtualProductId ' ;
498+ $ condition .= self :: AND . ' a.id != virtualProductId ' ;
496499
497500 break ;
498501
499502 case ProductListInterface::VARIANT_MODE_HIDE :
500503
501- $ condition .= " AND `type` != 'variant' " ;
504+ $ condition .= self :: AND . " `type` != 'variant' " ;
502505
503506 break ;
504507
505508 case ProductListInterface::VARIANT_MODE_VARIANTS_ONLY :
506509
507- $ condition .= " AND `type` = 'variant' " ;
510+ $ condition .= self :: AND . " `type` = 'variant' " ;
508511
509512 break ;
510513 }
511514
512515 if (!$ excludeConditions ) {
513516 $ userspecific = $ this ->buildUserspecificConditions ($ excludedFieldname );
514517 if ($ userspecific ) {
515- $ condition .= ' AND ' . $ userspecific ;
518+ $ condition .= self :: AND . $ userspecific ;
516519 }
517520 }
518521
@@ -529,7 +532,7 @@ protected function buildQueryFromConditions(bool $excludeConditions = false, ?st
529532 }
530533 }
531534
532- $ condition .= ' AND ' . $ this ->resource ->buildFulltextSearchWhere ($ this ->tenantConfig ->getSearchAttributes (), $ searchstring );
535+ $ condition .= self :: AND . $ this ->resource ->buildFulltextSearchWhere ($ this ->tenantConfig ->getSearchAttributes (), $ searchstring );
533536 }
534537
535538 $ this ->logger ->info ('Total Condition: ' . $ condition );
@@ -544,7 +547,7 @@ protected function buildUserspecificConditions(?string $excludedFieldname = null
544547 if ($ fieldname !== $ excludedFieldname ) {
545548 foreach ($ condArray as $ cond ) {
546549 if ($ condition ) {
547- $ condition .= ' AND ' ;
550+ $ condition .= self :: AND ;
548551 }
549552
550553 $ condition .= 'a.id IN (SELECT DISTINCT src FROM ' . $ this ->getCurrentTenantConfig ()->getRelationTablename () . ' WHERE ' . $ cond . ') ' ;
@@ -556,7 +559,7 @@ protected function buildUserspecificConditions(?string $excludedFieldname = null
556559 if ($ fieldname !== $ excludedFieldname ) {
557560 foreach ($ condArray as $ cond ) {
558561 if ($ condition ) {
559- $ condition .= ' AND ' ;
562+ $ condition .= self :: AND ;
560563 }
561564
562565 $ condition .= is_array ($ cond )
0 commit comments