@@ -1550,6 +1550,7 @@ public function addPriceData($customerGroupId = null, $websiteId = null)
1550
1550
* @param string $joinType
1551
1551
* @return $this
1552
1552
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
1553
+ * @SuppressWarnings(PHPMD.NPathComplexity)
1553
1554
*/
1554
1555
public function addAttributeToFilter ($ attribute , $ condition = null , $ joinType = 'inner ' )
1555
1556
{
@@ -1601,6 +1602,34 @@ public function addAttributeToFilter($attribute, $condition = null, $joinType =
1601
1602
}
1602
1603
}
1603
1604
1605
+ return $ this ;
1606
+ } elseif (is_string ($ attribute ) && $ attribute == 'tier_price ' ) {
1607
+ $ attrCode = $ attribute ;
1608
+ $ connection = $ this ->getConnection ();
1609
+ $ attrTable = $ this ->_getAttributeTableAlias ($ attrCode );
1610
+ $ entity = $ this ->getEntity ();
1611
+ $ fKey = 'e. ' . $ this ->getEntityPkName ($ entity );
1612
+ $ pKey = $ attrTable . '. ' . $ this ->getEntityPkName ($ entity );
1613
+ $ attribute = $ entity ->getAttribute ($ attrCode );
1614
+ $ attrFieldName = $ attrTable . '.value ' ;
1615
+ $ fKey = $ connection ->quoteColumnAs ($ fKey , null );
1616
+ $ pKey = $ connection ->quoteColumnAs ($ pKey , null );
1617
+
1618
+ $ condArr = ["{$ pKey } = {$ fKey }" ];
1619
+ $ joinMethod = 'join ' ;
1620
+ $ this ->getSelect ()->{$ joinMethod }(
1621
+ [$ attrTable => $ this ->getTable ('catalog_product_entity_tier_price ' )],
1622
+ '( ' . implode (') AND ( ' , $ condArr ) . ') ' ,
1623
+ [$ attrCode => $ attrFieldName ]
1624
+ );
1625
+ $ this ->removeAttributeToSelect ($ attrCode );
1626
+ $ this ->_filterAttributes [$ attrCode ] = $ attribute ->getId ();
1627
+ $ this ->_joinFields [$ attrCode ] = ['table ' => '' , 'field ' => $ attrFieldName ];
1628
+ $ field = $ this ->_getAttributeTableAlias ($ attrCode ) . '.value ' ;
1629
+ $ conditionSql = $ this ->_getConditionSql ($ field , $ condition );
1630
+ $ this ->getSelect ()->where ($ conditionSql , null , Select::TYPE_CONDITION );
1631
+ $ this ->_totalRecords = null ;
1632
+
1604
1633
return $ this ;
1605
1634
} else {
1606
1635
return parent ::addAttributeToFilter ($ attribute , $ condition , $ joinType );
0 commit comments