0

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:-

  1. Get the customer collection. $collection
  2. 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.

2
  • can you specify your requirement in more details with why you needed address information here? Commented Jul 16, 2021 at 4:20
  • @DhirenVasoya, I don't need address here. What i am saying that i want to fetch those customer record (customer_entity table) whose address has been changed. If we see address is stored in customer_address_entity table, When we change the customer address then its customer_address_entity table which gets updated (updated_at column in table). In this case we have to join these tables to get the customer_entity data right ? Commented Jul 16, 2021 at 4:29

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.