To query customers who have specifically changed their name or address in Magento 2 since yesterday, you can approach the problem by below steps:
Create an Observer: Use the events customer_save_after
and customer_address_save_after
.
In your observer, check if the relevant fields (name, address) have changed.
Create a Custom Table: You might want to create a custom table with columns like entity_id, customer_id, changed_field, and changed_at.
Save Changes in custom table: In the observer, if the name or address has changed, save the customer ID and timestamp in your custom table.
Query for Changes: Use a SQL query to select customers from your custom table where changed_at is greater than yesterday's date.
then you can filter data from the custom table using below query
SELECT customer_id
FROM your_custom_table
WHERE changed_at >= DATE_SUB(NOW(), INTERVAL 1 DAY);