Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Invalid address id" when adding product to basket Magento2 #7570

Closed
sma09sjb opened this issue Nov 25, 2016 · 46 comments
Closed

"Invalid address id" when adding product to basket Magento2 #7570

sma09sjb opened this issue Nov 25, 2016 · 46 comments
Labels
bug report Component: Checkout Issue: Format is not valid Gate 1 Failed. Automatic verification of issue format is failed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development

Comments

@sma09sjb
Copy link

Steps to reproduce

  1. Login
  2. Add a product to your basket (remember which product you added)
  3. Go to checkout and select a delivery address (do not process a transaction)

The database now has a quote_address entity which has a customer_address_id
untitled

  1. Remove the product from basket
  2. Delete the address you selected from your account
  3. add the same product as before to your basket
  4. try and remove the product

Expected result

  1. You should be able to remove the product from your basket without an error being thrown.

Actual result

image
When you add the same product to your basket the code looks for an existing quote for that user, and it finds one in the above scenario but because the address associated to is now no longer in existence it throws this error.

What needs to happen is when an address is deleted the quotes should be checked for any quote_addresses with that customer_address_id referenced, and then it should be deleted.

@veloraven
Copy link
Contributor

@sma09sjb thank you for your report.
Please, also identify which version of Magento you are running.

@sma09sjb
Copy link
Author

@veloraven apologies, the magento version is 2.1.2

@SerhiyShkolyarenko SerhiyShkolyarenko self-assigned this Nov 29, 2016
@SerhiyShkolyarenko SerhiyShkolyarenko added the Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development label Nov 29, 2016
@SerhiyShkolyarenko
Copy link
Contributor

@sma09sjb thank you for very clear bug report!
Created internal issue MAGETWO-61551.

@sma09sjb
Copy link
Author

sma09sjb commented Dec 2, 2016

Can i have an update on this please?

@SerhiyShkolyarenko
Copy link
Contributor

The ticket is in queue for fixing. It's marked as high priority.

@mgomma
Copy link

mgomma commented Jan 5, 2017

Does there exist a patch for that issue as it blocks going live, It happens with me after failed payment operation.

causes add to cart to fail and reload the page. and when doing reorder.

@davidstillson
Copy link

davidstillson commented Jan 11, 2017

We are also experiencing this bug in 2.1.3.

I will say that when I replicate this issue, it doesn't matter if I try to add the same product to cart or a different one. If I've created a quote from an address in the account, and that address get's deleted after quote creation, it produces the error when trying to add products.

So once I remove the items from cart, then delete the address used from the account, I can't add any products to cart. If I manually delete the records from the quote_address table, I am able to add items to cart again.

@Flipmediaco
Copy link

I believe this issue is created as the address id stored in customer_entity for default_shipping has been removed from customer_address_entity.

@mgomma
Copy link

mgomma commented Jan 25, 2017

@Flipmediaco I totally agree with you as that error disappear when the customer set default shipping and billing address

@cherreman
Copy link

We are experiencing the same issue when removing an item from the basket. (We are running 2.1.2)

Is there any update on this?

@cherreman
Copy link

This Gist fixes this issue by setting the billing and shipping addresses to the customers defaults: https://gist.github.com/cherreman/e35590981bf8a53a086a66c8a4f86fad

@sdzhepa
Copy link
Contributor

sdzhepa commented Mar 6, 2017

@sma09sjb, @davidstillson, @cherreman
This bug has already fixed in scope of MAGETWO-62044 for the latest version(develop branch)

  • Fix for 2.1 will be delivered in scope of MAGETWO-64068
  • Fix for 2.0 will be delivered in scope of MAGETWO-64069

@sdzhepa sdzhepa closed this as completed Mar 6, 2017
@eInyzant
Copy link

is it really fixed already ?
I still have this issue on magento 2.1.6

@sammarcus
Copy link
Contributor

I am also (still) experiencing this on 2.1.7 CE

@fronke
Copy link

fronke commented Aug 24, 2017

I am also still experiencing this on 2.1.7 CE

@AlexanderHuyghebaert
Copy link

Also can confirm that this issue still exists in 2.1.7 CE

@germaike
Copy link

germaike commented Sep 6, 2017

Hi, i'm still having this problem. I can not clear customers shopping cart.
error : Invalid customer address id 7494
version : ce 2.1.4

Is it possible to delete the cart at database Level?
Please reopen ticket!

@rijadhusic
Copy link

I am also (still) experiencing this on 2.1.8 EE

@conflicker
Copy link

I'm getting this issue on 2.1.7 CE, any solution?

@magento-engcom-team magento-engcom-team added the Issue: Format is not valid Gate 1 Failed. Automatic verification of issue format is failed label Sep 13, 2017
@conflicker
Copy link

@magento-engcom-team what is G1 Failed label means?

@magento-engcom-team
Copy link
Contributor

Hi @conflicker G1 Failed (Gate 1 Failed) means the issue description did not pass automatic verification of the issue description. We will publish more details soon about Gates system.

@spraxis
Copy link

spraxis commented Oct 19, 2017

A quick and dirty solution could be to create a Plugin and clear the customer_address_id from the quote_address table everytime an address is deleted.

di.xml

<type name="\Magento\Customer\Model\ResourceModel\Address">
    <plugin name="mycompany_quote_address_fix_plugin"
            type="MyCompany\QuoteAddressFix\Plugin\AddressPlugin"
            sortOrder="1"
            disabled="false"/>
</type>

app/code/MyCompany/QuoteAddressFix/Plugin/AddressPlugin.php

<?php
namespace MyCompany\QuoteAddressFix\Plugin;

use Magento\Framework\App\ResourceConnection;
use Psr\Log\LoggerInterface;
use Magento\Customer\Model\ResourceModel\Address;

/**
 * Class AddressPlugin
 * @package MyCompany\QuoteAddressFix\Plugin
 */
class AddressPlugin
{
    /**
     * @var \Magento\Framework\App\ResourceConnection
     */
    protected $resourceConnection;

    /**
     * @var \Psr\Log\LoggerInterface
     */
    protected $logger;

    /**
     * @param ResourceConnection $resourceConnection
     * @param LoggerInterface $logger
     */
    public function __construct(
        ResourceConnection $resourceConnection,
        LoggerInterface $logger
    ) {
        $this->resourceConnection = $resourceConnection;
        $this->logger = $logger;
    }

    /**
     * Clear customer addresses from the quote_address table
     * M2 Bug: https://github.com/magento/magento2/issues/7570
     *
     * @param Address $subject
     * @param \Closure $proceed
     * @param object $address
     * @return mixed
     */
    public function aroundDelete(Address $subject, \Closure $proceed, $address)
    {
        try {
            $this->resourceConnection->getConnection()->fetchRow("
                UPDATE quote_address
                SET customer_address_id = NULL
                WHERE customer_address_id = '" . $address->getId() . "'
            ");
        } catch (\Exception $e) {
            $this->logger->critical($e->getMessage());
        }
        return $proceed($address);
    }
}

@benyanke
Copy link

benyanke commented Mar 15, 2018

Any update on this, @magento? Still a breaking issue for us.

@williankeller
Copy link
Member

Hey guys, do we have any updated on this? We still facing this issue

@benyanke
Copy link

Hi Willian, did you try the plugin three posts up? We installed it on our site, and we haven't seen it since.

@williankeller
Copy link
Member

Hi @benyanke, no, is it working to EE as well?

@benyanke
Copy link

Yes, we're EE.

@Rita-ti
Copy link

Rita-ti commented Nov 21, 2018

For a quick solution, please go through this below link:
https://magento.stackexchange.com/a/196149/52030

@Adr79
Copy link

Adr79 commented May 18, 2019

We have same issue on magento 2.3.1.
Is this issue being investigated?

@apaolino
Copy link

apaolino commented Jun 2, 2019

Still have it on 2.3.1 CE

@TheLaughingThird
Copy link

Still have it on 2.3.2 great this magento 2 platform, first the incredible 2.2 version and also the constant changes makes it real ease to work with... NOT !

@engcom-Bravo engcom-Bravo self-assigned this Jul 25, 2019
@m2-assistant
Copy link

m2-assistant bot commented Jul 25, 2019

Hi @engcom-Bravo. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: 👇

  • 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).

    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.

  • 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • 4. Verify that the issue is reproducible on 2.3-develop branch

    Details- Add the comment @magento give me 2.3-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.3-develop branch, please, add the label Reproduced on 2.3.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

  • 5. Verify that the issue is reproducible on 2.2-develop branch.

    Details- Add the comment @magento give me 2.2-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.2-develop branch, please add the label Reproduced on 2.2.x

  • 6. Add label Issue: Confirmed once verification is complete.

  • 7. Make sure that automatic system confirms that report has been added to the backlog.

@engcom-Charlie
Copy link
Contributor

engcom-Charlie commented Jul 26, 2019

I can't reproduce this issue on fresh Magento 2.3-develop and 2.3.2 branches.

Manual testing scenario:
1.Login to admin
2.Create a simple product
3. Go to customer view
4.Login to customer account
5.Add a product to your basket (remember which product you added)
6.Go to checkout and select a delivery address (do not process a transaction)
7.Back to the cart
8.Remove the product from basket
9.Go to the My Account-->Address Book
10.Add new address and select it as default(because you can't delete current address if you doesn't have another one)
11.Delete the previous address you selected from your account
12.Add the same product as before to your basket
13.try to remove the product from a cart

Actual result:
Product deleted from cart


Hi, @b2bdokter ! Can you provide me your steps to reproduce this issue?

@TheLaughingThird
Copy link

TheLaughingThird commented Jul 26, 2019

Yesterday my customer reported after I told him to order a item:

It says costumer invalid adress id 3832, when i try

At the moment , I am not be able to login to the magento backend ( out of the blue) so my first 2 hours I need to solve that again... But it is such a buggy platform I can't believe it seriously considering to start using another CMS system in the future, Tons of bugs, a lot of them are not even solved ... Only one benefiting from M2 are the developers with their expensive extensions you need to renew...

Just insert a new password, try to login and it wont let me , its such a good platform for E-Concerns

So I am sorry it seems like I wont be able to help to reproduce because loggin into magento 2.3.2 seems difficult enough

@engcom-Charlie
Copy link
Contributor

@b2bdokter , you can try to reproduce it on fresh 2.3-develop instance. I will request instance for you.

@engcom-Charlie
Copy link
Contributor

@magento give me 2.3-develop instance

@magento-engcom-team
Copy link
Contributor

Hi @engcom-Charlie. Thank you for your request. I'm working on Magento 2.3-develop instance for you

@magento-engcom-team
Copy link
Contributor

Hi @engcom-Charlie, here is your Magento instance.
Admin access: https://i-7570-2-3-develop.instances.magento-community.engineering/admin
Login: admin Password: 123123q
Instance will be terminated in up to 3 hours.

@TheLaughingThird
Copy link

TheLaughingThird commented Jul 26, 2019

Okay @magento-engcom-team Give me one please thank you

@engcom-Charlie
Copy link
Contributor

@b2bdokter use it:
Admin access: https://i-7570-2-3-develop.instances.magento-community.engineering/admin
Login: admin Password: 123123q
Instance will be terminated in up to 3 hours.

@TheLaughingThird
Copy link

Tried to reproduce on that installation , cant reproduce.

But since it happens on our own installation.
Whats more important to me and others still experiencing this... What can we do to solve this ?

customer invalid adress id 3832

I see no decent solution anywere...

@Flipmediaco
Copy link

Flipmediaco commented Jul 26, 2019

@b2bdokter This is a data issue...

The table customer_address_entity has a foreign key named customer_address_id of 3832 which is the primary key entity_id of customer_address_entity... If you review these two tables, I suspect you will find the address identified byentity_id 3832 is no longer present, yet a reference in another table remains. The exact specifics of this will likely be unique to your instance.

This thread is closed as the original issue was resolved and update applied that changed the customer_entity so it did not store an address foreign key of customer_address_entity in default_shipping.

If you can recreate the steps that has caused the data inconsistency, then open a new ticket detailing this 👍

Good luck and I guess you will find the solution in the data and once the reference to 3832 is removed, the issue will go away.

Hope this helps, have a great day

@engcom-Bravo engcom-Bravo removed their assignment Jul 26, 2019
@TheLaughingThird
Copy link

Thank you @Flipmediaco for your time ,have a great day too

magento-devops-reposync-svc pushed a commit that referenced this issue Apr 18, 2022
…heck-dependencies

SEARCH-1968: Static tests to check for dependency of Elasticsearch
@fm-cl
Copy link

fm-cl commented May 26, 2022

im having this issue on magento 2.4.2p2, only with certain customers

@vipin1211987
Copy link

$connection->query("update customer_entity ce set default_billing = null where default_billing is not null and default_billing != 0 and default_billing not in (select entity_id from customer_address_entity where parent_id = ce.entity_id);");

$connection->query("update customer_entity ce set default_shipping = null where default_shipping is not null and default_shipping != 0 and default_shipping not in (select entity_id from customer_address_entity where parent_id = ce.entity_id);");

@vandark25
Copy link

Solved in #23618

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report Component: Checkout Issue: Format is not valid Gate 1 Failed. Automatic verification of issue format is failed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development
Projects
None yet
Development

No branches or pull requests