In Magento I need to get products without special price within a specific category.
Here is what I come up with:
<?php
$dateYesterday = date( 'm/d/y', mktime( 0, 0, 0, date( 'm' ), date( 'd' ) - 1, date( 'y' ) ) );
$catagoryModel = Mage::getModel( 'catalog/category' )->load( $currentCategoryId );
$productCollection = Mage::getResourceModel( 'catalog/product_collection' );
$productCollection->addAttributeToSelect( 'name' );
$productCollection->addCategoryFilter( $catagoryModel );
$productCollection->addAttributeToFilter( 'special_price',
array( 'eq' => '' )
);
$productCollection->addAttributeToFilter( 'special_to_date',
array( 'date' => true, 'to' => $dateYesterday )
);
?>
In the above query, I need to use the "OR" conditional between the two last filters, semantically like this:
$productCollection->addAttributeToFilter( 'special_price',
array( 'eq' => '' ) );
// OR
$productCollection->addAttributeToFilter( 'special_to_date',
array( 'date' => true, 'to' => $dateYesterday ) );
In other words:
( special_price = '' OR special_to_date <= $dateYesterday )
Can you help? Thanks!