I am trying to fetch the customer record which is updated. Customer update implies both customer entity as well as customer's address.
I am relying on the updated_at column which technically says that this record has been updated. I am trying with below approach:-
- Get the customer collection. $collection
- Add filter on updated_at $collection->addFieldToFilter('updated_at', ['gt' => $startTime]); $collection->addFieldToFilter('updated_at', ['lt' => $endTime]);
This gives me the below query:-
SELECT `e`.* FROM `customer_entity` AS `e` WHERE (`e`.`website_id` = '1') AND (`e`.`updated_at` > '2021-07-14T08:45:06Z[UTC]') AND (`e`.`updated_at` < '2021-07-16T08:13:00.129Z[UTC]') LIMIT 4
This gives us only customer data.
However, I want a query like the below:-
SELECT c.* FROM magento.customer_entity as c inner join magento.customer_address_entity as a on c.default_billing=a.entity_id WHERE (`c`.`website_id` = '1') AND ((`c`.`updated_at` > '2021-07-14T08:45:06Z[UTC]') AND (`c`.`updated_at` < '2021-07-16T08:13:00.129Z[UTC]')) or ((`a`.`updated_at` > '2021-07-14T08:45:06Z[UTC]') AND (`a`.`updated_at` < '2021-07-16T08:13:00.129Z[UTC]')) LIMIT 4
How to approach this? I am a new Magento extension developer.