1

I am facing the below problem when requesting the customer list:

Critical: Report ID: webapi-600ad6e880167; Message: Item (Magento\Customer\Model\Customer\Interceptor) with the same ID "6827" already exists.

Request URI: /index.php/rest/V1/customers/search?searchCriteria%5Bfilter_groups%5D%5B0%5D%5Bfilters%5D%5B0%5D%5Bfield%5D=updated_at&searchCriteria%5Bfilter_groups%5D%5B0%5D%5Bfilters%5D%5B0%5D%5Bvalue%5D=2021-01-01%2009:23:26&searchCriteria%5Bfilter_groups%5D%5B0%5D%5Bfilters%5D%5B0%5D%5Bcondition_type%5D=gt&searchCriteria%5Bsort_orders%5D%5B0%5D%5Bfield%5D=updated_at&searchCriteria%5Bsort_orders%5D%5B0%5D%5Bdirection%5D=ASC&searchCriteria%5Bpage_size%5D=101&searchCriteria%5Bcurrent_page%5D=1

[2021-01-22 15:18:23] main.CRITICAL: Report ID: webapi-600aecbf05b0d; Message: Item (Magento\Customer\Model\Customer\Interceptor) with the same ID "6827" already exists. {"exception":"[object] (Exception(code: 0): Report ID: webapi-600aecbf05b0d; Message: Item (Magento\Customer\Model\Customer\Interceptor) with the same ID "6827" already exists. at /var/www/vhosts/domain.com/httpdocs/vendor/magento/framework/Webapi/ErrorProcessor.php:208, Exception(code: 0): Item (Magento\Customer\Model\Customer\Interceptor) with the same ID "6827" already exists. at /var/www/vhosts/domain.com/httpdocs/vendor/magento/framework/Data/Collection.php:408)"} []

I have no clue how to fix this? The customer indeed exists when looking up the ID in the backend, but I cant seem to find any duplicate IDs. Can I somehow debug it further to know in which table I need to look?

Thanks!

1
  • Would be great if someone can help me debug it.. Spend a lot of hours already..
    – JorgB
    Jan 26, 2021 at 7:55

2 Answers 2

2

I recently ran in to this problem. It was caused by duplicate newsletter subscribers. Because of this the MySQL join resulted in two customer records being returned with the same ID when searching in the customer repository via the API.

1
  • 1
    This was it indeed! Eventually found out but didn't update it here, so accepted your answer! Thanks :)
    – JorgB
    May 19, 2021 at 9:37
2

I think some issue happen on join collection,

Go to

\Magento\Customer\Model\ResourceModel\CustomerRepository::getList

and after $this->collectionProcessor->process($searchCriteria, $collection); and print the sql query using $collection->getSelect()->__toString(). __toString() give sql query and run query and you can find 6827 has duplicated record. and your need to delete repective duplicate data. That will be resolved that issue.

Or

temp solution is after $this->collectionProcessor->process($searchCriteria, $collection); that add below code $collection->getSelect()->group('e.entity_id')

4
  • Thanks Amit! Will this print the query in a Magento log file?
    – JorgB
    Jan 26, 2021 at 8:23
  • echoing echo $collection->getSelect()->__toString()
    – Amit Bera
    Jan 26, 2021 at 8:50
  • Mm I dont seem to get anything as output in the log files. I have this now: $this->collectionProcessor->process($searchCriteria, $collection); echo $collection->getSelect()->__toString(); $searchResults->setTotalCount($collection->getSize());
    – JorgB
    Jan 26, 2021 at 10:36
  • I guess this is it? ` [2021-01-26 15:59:34] main.DEBUG: SQL Select: ["(website_id = :website_id)","AND (dest_country_id = :country_id AND dest_region_id = :region_id AND STRCMP(LOWER(dest_city),LOWER(:city))= 0 AND :postcode LIKE dest_zip )","AND (condition_name = :condition_name)","AND (condition_from_value < :condition_value)","AND (condition_to_value >= :condition_value)"] [] `
    – JorgB
    Jan 26, 2021 at 16:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.