diff --git a/code/local/Evozon/Blog/Model/Resource/Indexer/UrlRewrite/Data/Source.php b/code/local/Evozon/Blog/Model/Resource/Indexer/UrlRewrite/Data/Source.php index 10a96cb..06495aa 100644 --- a/code/local/Evozon/Blog/Model/Resource/Indexer/UrlRewrite/Data/Source.php +++ b/code/local/Evozon/Blog/Model/Resource/Indexer/UrlRewrite/Data/Source.php @@ -105,13 +105,19 @@ public function getAttributesValue() $select->where('e.entity_id IN (?)', $postIds); } + if (stristr($attrCode, 'date')) { + $expr = new Zend_Db_Expr("IF (joins.{$attrCode} IS NULL, joins.{$attrCode}_default, joins.{$attrCode} ) AS {$attrCode}"); + } else { + $expr = new Zend_Db_Expr("IF (joins.{$attrCode} IS NULL OR joins.{$attrCode} = '', joins.{$attrCode}_default, joins.{$attrCode} ) AS {$attrCode}"); + } + $selectSql = $adapter->select() ->from( array('joins' => $select), array( 'entity_id' => 'joins.entity_id', 'store_id' => "joins.{$attrCode}_store", - new Zend_Db_Expr("IF (joins.{$attrCode} IS NULL OR joins.{$attrCode} = '', joins.{$attrCode}_default, joins.{$attrCode} ) AS {$attrCode}") + $expr ) ); @@ -177,4 +183,4 @@ public function getStoreIds() { return $this->_storeIds; } -} \ No newline at end of file +}