Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

E-Commerce Modules /

Discuss about the various e-commerce modules available:
Ecommerce, SS Shop, SilverCart and SwipeStripe
Alternatively, have a look the shared mailinglist.

Moderators: martimiz, Nicolaas, Sean, Ed, frankmullenger, biapar, Willr, Ingo, Jedateach, swaiba

Silvershop Discounts Sale Category: Search Filter modifier for 'IS NULL'


Go to End


1518 Views

Avatar
Vix

Community Member, 60 Posts

24 November 2016 at 7:16pm

Edited: 24/11/2016 7:18pm

I have a site set up using Silvershop and the Discounts module and I wanted to create a 'sale category' page. The problem I am running into is that products can be given a 'Specific Price' and you can save them without having an end date entered. So a product can be on special from today indefinitely, which is fine, I want that flexibility. However I don't seem to be able to create a query to get these records where the end date is null.

$now = date('Y-m-d');
$do = SpecificPrice::get()->filter(array('StartDate:LessThanOrEqual' => $now))->filterAny(array("EndDate:GreaterThanOrEqual" => $now, "EndDate" => "NULL"));

This retrieves the products that have an end date specified, but not those that have a NULL value in the database. I have tried:

"EndDate" => "NULL"
"EndDate:is" => "NULL"
"EndDate" => ""
"EndDate" => " "
"EndDate" => NULL
"EndDate" => false

So how do I get these records in my query?

Thanks