0

I've developed a Magento website and i want to we select a customer each period of time within order than $1000 and give him a prize from the admin.

Any suggestion about that ?

Mahmoud Ismail
  • 1,611
  • 4
  • 26
  • 50
  • I'm voting to close this question as off-topic because Stack Overflow is a [programming-related](http://stackoverflow.com/help/on-topic) Q&A site. Your question is not about programming. Perhaps you should post it on http://magento.stackexchange.com instead? – Enigmativity Oct 30 '16 at 08:14

1 Answers1

0

Magento uses a mysql DB.

I don't know the DB schema really. Find a query that gives you all orders > $1000 for the given time interval. Then just pick a random row from the result. See answer Mysql 1 Random Row

Something like

SELECT DISTINCT customer_id from sales_order 
WHERE created_at between ? and ? 
AND grand_total > 1000 
ORDER BY RAND() LIMIT 1

could actually work. It will have a customer_id that you can then lookup in the customer_entity table.

Because I use DISTINCT in my query, even if a customer placed more than 1 $1000 order he only gets one chance at winning just like the other customers that placed only 1 $1000 order in the given time interval.

neuhaus
  • 3,588
  • 1
  • 9
  • 24