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

Address Information not showing #5873

Closed
ComputerNorth opened this issue Jul 28, 2016 · 72 comments
Closed

Address Information not showing #5873

ComputerNorth opened this issue Jul 28, 2016 · 72 comments
Labels
bug report Component: Sales Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed

Comments

@ComputerNorth
Copy link

ComputerNorth commented Jul 28, 2016

Preconditions

Magento 2.1

Steps to reproduce

In the admin panel go to Sales --> Orders --> select an order

Expected result

In both the Billing Address and Shipping Address I expect to see the address details of the customer. However the actual result is:

Address Information
Billing Address

{{depend prefix}}{{var prefix}} {{/depend}}{{var firstname}} {{depend middlename}}{{var middlename}} {{/depend}}{{var lastname}}{{depend suffix}} {{var suffix}}{{/depend}}{{depend firstname}}
{{/depend}} {{depend company}}{{var company}}
{{/depend}} {{if street1}}{{var street1}}
{{/if}} {{depend street2}}{{var street2}}
{{/depend}} {{depend street3}}{{var street3}}
{{/depend}} {{depend street4}}{{var street4}}
{{/depend}} {{if city}}{{var city}}, {{/if}}{{if region}}{{var region}}, {{/if}}{{if postcode}}{{var postcode}}{{/if}}
{{var country}}
{{depend telephone}}T: {{var telephone}}{{/depend}} {{depend fax}}
F: {{var fax}}{{/depend}} {{depend vat_id}}
VAT: {{var vat_id}}{{/depend}}

I'm looking forward to a solution, Thanks,

@andimov
Copy link
Contributor

andimov commented Jul 29, 2016

@ComputerNorth
Thanks for reporting!

Try to clear browser cache or open this page in another browser.
If this does not help, add a screenshot of the page with the open console.

@ComputerNorth
Copy link
Author

magento-scr

It happens in FireFox, IE and Chrome, clear browser cache doesn't help

@gahehe
Copy link

gahehe commented Aug 1, 2016

Pump. Need urgent fix for it.

@andimov
Copy link
Contributor

andimov commented Aug 1, 2016

@gahehe
Do you have such view for all orders?
Have you tried to change data in order?
Please add screenshot with opened dev console, it's can consists some js errors.

@gahehe
Copy link

gahehe commented Aug 1, 2016

Hi @andimov,

This is not only in order view, but also everywhere that displayed the customer address by template and calling the \Magento\Customer\Block\Address\Book::getAddressHtml() method.
For example, in the Customer Address Book:
untitled

Tried to var_dump what this function returned, and it returned this also. I don't think it is JS issue.

@andimov
Copy link
Contributor

andimov commented Aug 2, 2016

Looks like it relates to
#4936

@ComputerNorth @gahehe
Did you migrate from a previous version?

@ComputerNorth
Copy link
Author

Yes I did migrate from magento 1.8.1

@gahehe
Copy link

gahehe commented Aug 2, 2016

OK Found the solution.

@ComputerNorth, please check your database, the eav_entity_type table. The entity code "customer_address" must have id as 2, because in the \Magento\Customer\Api\AddressMetadataInterface, the id of "customer_address" type was fixed to 2 (the ATTRIBUTE_SET_ID_ADDRESS const). In my case, the "customer_address" entry, somehow changed ID to 4 (it's weird, because the fresh eav_entity_type has the ID column increment as 1,2,3..., but mine 2,4,6,8...). So I need to rewrite the function to use 4 instead of 2 as id, then everything came back to normal.

@ComputerNorth
Copy link
Author

Thank you, but unfortunately for me this is not a solution. My eav_entity_type has the ID column increment as 1,2,3 and entity type id =2 for the entity type code "customer_address".

@milanstojanov
Copy link

I can confirm this issue! Happens after I have upgraded from 1.7.0.2 to 2.1.0. Any solutions so far?

@milanstojanov
Copy link

milanstojanov commented Aug 29, 2016

In my case, @gahehe point was almost there, but I figured it out after reviewing the thread, since it was a bit different.

The migration tool added a couple of rows to the end of eav_attribute_set table (didn't mess up increment ids as it was in his case). So for example, I see a row added:

+------------------+----------------+--------------------+------------+
| attribute_set_id | entity_type_id | attribute_set_name | sort_order |
+------------------+----------------+--------------------+------------+
| 41 | 2 | Default | 2 |
+------------------+----------------+--------------------+------------+

41 is used to reference customer address attribute set in some of the other tables. So the solution comes down to changing Magento\Customer\Api\AddressMetadataInterface::ATTRIBUTE_SET_ID_ADDRESS to 41 in my case.

I am pretty sure this is going to be fixed in some of the next releases of the tool, but until then - hopefully this will be helpful to someone.

@ComputerNorth
Copy link
Author

Thanks milanstojanov. For me the default attribute is:

+------------------+----------------+--------------------+------------+
| attribute_set_id | entity_type_id | attribute_set_name | sort_order |
+------------------+----------------+--------------------+------------+
| 4 | 4 | Default | 1 |
+------------------+----------------+--------------------+------------+
So I changed Magento\Customer\Api\AddressMetadataInterface::ATTRIBUTE_SET_ID_ADDRESS to 4. Unfortunately it didn't solve the issue.

@milanstojanov
Copy link

milanstojanov commented Sep 5, 2016

Please check the table again. I am pretty sure you will find a record at the very bottom that has entity_type_id = 2. That one needs to be changed, not the top one. :)

@daschenbrener
Copy link

I as well have this same issue, and the entity_type_id = 2 in the Eav Entity Type table. and I also upgraded from 1.9.2.2 to 2.1.0

@bst2002git
Copy link

bst2002git commented Oct 25, 2016

Hello,
i'v installed Magento 2.0.1 and upgraded to 2.1.2 and wondered why instead address is shown the template format variables {{}}.... an the problem is the "auto_increment_increment=5" (percona mysql cluster) is set to internal 5, so it increments 5,10,15,20,25...
So my question is what can i do, changing Hard-Coded IDs in Magento? What about when i update Magento, must remember to change this every time, not a good Idea?

Which changes do i need to make in the database in which tables to assign the Hard-Coded IDs of Magento

Thats a big Problem

@sanjayjethva
Copy link

I am facing the same issue in Magento 2.1.6
Let me know if any one has a better solution.
Thanks

@refaelgold
Copy link

i follow as well..

@refaelgold
Copy link

refaelgold commented May 24, 2017

I really struggle with this. i try to change it 3 times and the customer address still not give me the correct values.

When i try to edit it - i can see the corrcet values inside

@nowsathyasar
Copy link

I am facing the same issue in Magento 2.2.5
Let me know if any one has a better solution.
Thanks

@nowsathyasar
Copy link

Billing Address Edit
{{depend prefix}}{{var prefix}} {{/depend}}{{var firstname}} {{depend middlename}}{{var middlename}} {{/depend}}{{var lastname}}{{depend suffix}} {{var suffix}}{{/depend}}{{depend firstname}}
{{/depend}} {{depend company}}{{var company}}
{{/depend}} {{if street1}}{{var street1}}
{{/if}} {{depend street2}}{{var street2}}
{{/depend}} {{depend street3}}{{var street3}}
{{/depend}} {{depend street4}}{{var street4}}
{{/depend}} {{if city}}{{var city}}, {{/if}}{{if region}}{{var region}}, {{/if}}{{if postcode}}{{var postcode}}{{/if}}
{{var country}}
{{depend telephone}}T: {{var telephone}}{{/depend}} {{depend fax}}
F: {{var fax}}{{/depend}} {{depend vat_id}}
VAT: {{var vat_id}}{{/depend}}
Shipping Address Edit
{{depend prefix}}{{var prefix}} {{/depend}}{{var firstname}} {{depend middlename}}{{var middlename}} {{/depend}}{{var lastname}}{{depend suffix}} {{var suffix}}{{/depend}}{{depend firstname}}
{{/depend}} {{depend company}}{{var company}}
{{/depend}} {{if street1}}{{var street1}}
{{/if}} {{depend street2}}{{var street2}}
{{/depend}} {{depend street3}}{{var street3}}
{{/depend}} {{depend street4}}{{var street4}}
{{/depend}} {{if city}}{{var city}}, {{/if}}{{if region}}{{var region}}, {{/if}}{{if postcode}}{{var postcode}}{{/if}}
{{var country}}
{{depend telephone}}T: {{var telephone}}{{/depend}} {{depend fax}}
F: {{var fax}}{{/depend}} {{depend vat_id}}
VAT: {{var vat_id}}{{/depend}}

@nowsathyasar
Copy link

Hi Guy's

Have you resolved this issue, I am badly stuck also... please let me know solution ??

@nowsathyasar
Copy link

I had the same issue on 2.2.5..
Here is the solution which worked for me for anyone still having this issue on 2.2.5
replace this file vendor\magento\module-sales\Model\Order\Address\Renderer.php
with latest of magento version 2.2.5

@nowsathyasar
Copy link

`<?php
/**

  • Copyright © Magento, Inc. All rights reserved.
  • See COPYING.txt for license details.
    */

namespace Magento\Sales\Model\Order\Address;

use Magento\Framework\Event\ManagerInterface as EventManager;
use Magento\Framework\Filter\FilterManager;
use Magento\Framework\DataObject;

/**

  • Class Renderer used for formatting a store address
    */
    class Renderer
    {
    const DEFAULT_TEMPLATE = "{{var firstname}}".
    "{{depend middlename}}{{var middlename}}{{/depend}}".
    "{{var lastname}}\n".
    "{{var company}}\n".
    "{{var street}}\n".
    "{{var city}}\n".
    "{{var region}}\n".
    "{{var postcode}}\n".
    "{{var telephone}}\n".
    "{{var country_id}}\n";

    /**

    • @var EventManager
      */
      protected $eventManager;

    /**

    • @var FilterManager
      */
      protected $filterManager;

    /**

    • @var string
      */
      private $template;

    /**

    • Constructor
    • @param EventManager $eventManager
    • @param FilterManager $filterManager
    • @param string $template
      */
      public function __construct(
      EventManager $eventManager,
      FilterManager $filterManager,
      $template = self::DEFAULT_TEMPLATE
      ) {
      $this->eventManager = $eventManager;
      $this->filterManager = $filterManager;
      $this->template = $template;
      }

    /**

    • Format address in a specific way

    • @param DataObject $storeInfo

    • @param string $type

    • @return string
      */
      public function format(DataObject $storeInfo, $type = 'html')
      {
      $this->eventManager->dispatch('store_address_format', ['type' => $type, 'store_info' => $storeInfo]);
      $address = $this->filterManager->template(
      $this->template,
      ['variables' => $storeInfo->getData()]
      );

      if ($type == 'html') {
      $address = nl2br($address);
      }
      return $address;
      }
      }
      `

@ziaur1
Copy link

ziaur1 commented Oct 3, 2018

Kindly plz check ur database....default store view in store table from database..default= 0,english =1,

Your problem will be solve...

@nowsathyasar
Copy link

Kindly plz check ur database....default store view in store table from database..default= 0,english =1,

Your problem will be solve...

Thanks a lot Ziau1..this solution is working for me....

@swapnilkene
Copy link

@ziaur1 & @nowsathyasar can you please provide more details on what solution it is as its difficult to understand by your comments above.

@horebecommerce
Copy link

@nowsathyasar I just replaced your renderer.php code with Magento code which resolved the issue on order page, but on the customer view (both backend and frontend) it has the same issue which simply displays the template. Also wondering why we should make the customization on the core code?

Further Details:
I got this issue after upgrading from 2.1.x to 2.3.1 version

@hackronshins
Copy link

Hi, My recent upgrade is 2.3.1 as magento moves we are upgrading one by one, But we are having an issue which is on Paypal orders we are getting variable prefixes in billing address as email template format. Is there any fix to relates t its.

I tried all above solutions who got fixed, In database also I checked it is perfect. But why it is not fixed yet. We didn't touched anything in code.

Please help me to get a best solution for this.

13

@goutamfulcrum
Copy link

I am also facing same issue after upgrading magento to 2.3.1.

Anyone found solution for this?

@hackronshins
Copy link

hackronshins commented Jun 21, 2019 via email

@hackronshins
Copy link

`<?php
/**

  • Copyright © Magento, Inc. All rights reserved.
  • See COPYING.txt for license details.
    */

namespace Magento\Sales\Model\Order\Address;

use Magento\Framework\Event\ManagerInterface as EventManager;
use Magento\Framework\Filter\FilterManager;
use Magento\Framework\DataObject;

/**

  • Class Renderer used for formatting a store address
    /
    class Renderer
    {
    const DEFAULT_TEMPLATE = "{{var firstname}}".
    "{{depend middlename}}{{var middlename}}{{/depend}}".
    "{{var lastname}}\n".
    "{{var company}}\n".
    "{{var street}}\n".
    "{{var city}}\n".
    "{{var region}}\n".
    "{{var postcode}}\n".
    "{{var telephone}}\n".
    "{{var country_id}}\n";
    /
    *

    • @var EventManager
      */
      protected $eventManager;

    /**

    • @var FilterManager
      */
      protected $filterManager;

    /**

    • @var string
      */
      private $template;

    /**

    • Constructor

    • @param EventManager $eventManager

    • @param FilterManager $filterManager

    • @param string $template
      */
      public function __construct(
      EventManager $eventManager,
      FilterManager $filterManager,
      $template = self::DEFAULT_TEMPLATE
      ) {
      $this->eventManager = $eventManager;
      $this->filterManager = $filterManager;
      $this->template = $template;
      }

    /**

    • Format address in a specific way

    • @param DataObject $storeInfo

    • @param string $type

    • @return string
      */
      public function format(DataObject $storeInfo, $type = 'html')
      {
      $this->eventManager->dispatch('store_address_format', ['type' => $type, 'store_info' => $storeInfo]);
      $address = $this->filterManager->template(
      $this->template,
      ['variables' => $storeInfo->getData()]
      );
      if ($type == 'html') {
      $address = nl2br($address);
      }
      return $address;
      }
      }
      `

This render code file is for frontend, we are having an issue in backend admin side on sales->orders ->order details -> billing address. ( Billing address is showing in incorrect format like prefix variables with curly braces etc...!

@goutamfulcrum
Copy link

Any luck to anyone on this so far?

@mikehenze
Copy link

We have this issue in 2.3.2
Its for all orders and seems unrelated to paypal.

@mak0605
Copy link

mak0605 commented Aug 19, 2019

In Magento Default address ATTRIBUTE_SET_ID_ADDRESS is set to '2' (and this attribute set has default group id 2, that can be found in table) in class Magento\Customer\Api\AddressMetadataInterface;

While sometimes when we do use migration tool, it auto creates some bizarre attribute set and group with attribute set name 'Migration_Default', attribute group name 'Migration_General'.

So we have to do 2 things:

  1. Remove migration attribute set and group information from tables so that we can update the original one to id 2 and group id 2
  2. Add customer_address attributes to eav_entity_attribute table so that AttributeMeta class could use these attributes to parse address data.

Step 1. Remove migration attribute set and group information from tables so that we can update the original one to id 2 and group id 2

So you may need to find out what is your new default customer_address attribute set id and attribute_group_id ?

Use this to find new attribute set id.

select * from eav_attribute_set as eas inner join eav_attribute_group as eag on eag.attribute_set_id=eas.attribute_set_id where eas.entity_type_id=2 and eas.attribute_set_name='Default';

If you find a new id which is not '2'. Then you need to fix this because magento does have hard coded ATTRIBUTE_SET_ID_ADDRESS =2 and this is being used to run setup script in CustomerSetup.php.

So many other modules would be using this.
'entity_type_id' => \Magento\Customer\Api\AddressMetadataInterface::ATTRIBUTE_SET_ID_ADDRESS

So we need to fix this, we will have to remove that migration attribute set row and its group record. As well as we need to make default attribute set id for new id that we have found. I.e we have to set attribute_set_id =2 and group id =2

Note: Keep a note of migration attribute set id and attribute group id that will help you in the next step.


SET FOREIGN_KEY_CHECKS=0;
                 
"delete from eav_attribute_set where attribute_set_name='Migration_Default' and entity_type_id=2";
"Update eav_attribute_set SET attribute_set_id=2 where attribute_set_name='Default' and entity_type_id=2";

"delete from eav_attribute_group where attribute_group_name='Migration_General' and attribute_set_id=2";
"Update eav_attribute_group SET attribute_group_id=2, attribute_set_id=2 where attribute_group_id=19 and attribute_set_id=10";
SET FOREIGN_KEY_CHECKS=1;

Here attribute_group_id=19 is my default attribute group id for attribute_set_id=10, this is default magento customer attribute_set and group information, you may find 'attribute_group_code' for original attribute group in table 'eav_attribute_group', as Migration attribute set and group don't have attribute_group_code and tab_group_code;

Step 2. Add customer_address attributes to eav_entity_attribute table so that AttributeMeta class could use these attributes to parse address data

So now you need to check if attribute set, group and attribute id relation is maintained in table or not.
This is the main cause of unformatted address in magento. To do this:

SELECT * FROM eav_entity_attribute WHERE attribute_group_id = 2;

if you do not find any result set then try this query again with new attribute_set id ( migration attribute set id ) which you got from above query.

If you still don't have any result set then this is the problem. To Fix this we may need to insert entity type customer_attribute's attributes by using below command.

To check and verify before insertion:

SET @temp_row_number:=0;
Select ttab.*, @temp_row_number:=@temp_row_number+1 AS row_number, @temp_row_number*10 as sort_order From (SELECT ea.entity_type_id, ea.attribute_id,ea.attribute_code, eag.attribute_group_id, eas.attribute_set_id FROM eav_attributeas ea right join eav_attribute_set as eas on eas.entity_type_id=ea.entity_type_id and eas.attribute_set_name='Default' right join eav_attribute_group as eag on eag.attribute_set_id=eas.attribute_set_id where ea.entity_type_id=2 order by ea.attribute_id asc) as ttab;

To insert those records:

SET @temp_row_number:=0;

Insert into eav_entity_attribute (entity_type_id, attribute_set_id, attribute_group_id, attribute_id, sort_order)
Select ttab.*, (@temp_row_number:=@temp_row_number+1)*10 as sort_order From (SELECT ea.entity_type_id, eas.attribute_set_id,eag.attribute_group_id, ea.attribute_id FROM `eav_attribute` as ea right join eav_attribute_set as eas on eas.entity_type_id=ea.entity_type_id and eas.attribute_set_name='Default' right join eav_attribute_group as eag on eag.attribute_set_id=eas.attribute_set_id where ea.entity_type_id=2 order by ea.attribute_id asc) as ttab;

@mikehenze
Copy link

Some small typos:
eav_entity_attributenWHERE should be eav_entity_attribute WHERE (remove n)

eav_attributeas should be eav_attribute as (missing space)

@mak0605
Copy link

mak0605 commented Aug 19, 2019

Hey Mike,
Thanks for your response. I have made corrections.

@mikehenze
Copy link

Unfortunatly this does not fix the issue (for us).

@mikehenze
Copy link

I was able to fix the issue by replacing eav_entity_attribute with a copy from an older backup.

@oltskyi
Copy link

oltskyi commented Oct 9, 2019

in my case, it was necessary to change the way from
Magento\Customer\Model\ResourceModel\Attribute\Collection
to
Magento\Customer\Model\ResourceModel\Address\Attribute\Collection
in the table eav_entity_type, column: entity_attribute_collection

@KilalaPhu
Copy link

@mak0605 can you give me email: i send my database. could you fix this error help me. can fix it for 3 week i had search to fix it a lot. but i can not

@TurboPeter01
Copy link

TurboPeter01 commented Nov 6, 2019

@mak0605 can you give me email: i send my database. could you fix this error help me. can fix it for 3 week i had search to fix it a lot. but i can not

Go to your DB and find table eav_entity_attribute.
Rename this table, and import the same table from a backup.

After you done that the customer address on both front and backend will work again.

For some weird reason Magento updates all rows in this table ... not sure why yet, but i can easily reproduce the bug.

@yogeshkhasturi
Copy link

Same issue in Magento 2.3.5 after migration from 1.8.1,
https://prnt.sc/smz8ii

have you fixed this issue?

@monak83
Copy link

monak83 commented Nov 26, 2020

under Magento 2.3.6 problem exists yet. This is a very big bug!!! Any ideas?
paypal_issue

@WFEugenioCelant
Copy link

Hi,
since nobody wrote anything about it: missing information in the sales_order_address can also lead to this visual problem.

If you manually edit an entry in the sales_order_address table, saving all data as NULL, you will see in the backoffice the same result. In our case a third party module had a bug which wrongfully cleared the billing address, resulting in the aformentioned problem.

Show more...
  • Problem in DB:
> SELECT * FROM sales_order_address WHERE region_id IS NULL AND city IS NULL AND telephone IS NULL AND country_id IS NULL;
*************************** 1. row ***************************
              entity_id: 9782654
              parent_id: 4892177
    customer_address_id: NULL
       quote_address_id: 42967916
              region_id: NULL
            customer_id: NULL
                    fax: NULL
                 region: NULL
               postcode: NULL
               lastname: NULL
                 street: NULL
                   city: NULL
                  email: [email protected]
              telephone: NULL
             country_id: NULL
              firstname: NULL
           address_type: billing
                 prefix: NULL
             middlename: NULL
                 suffix: NULL
                company: NULL
                 vat_id: NULL
           vat_is_valid: NULL
         vat_request_id: NULL
       vat_request_date: NULL
    vat_request_success: NULL
   giftregistry_item_id: NULL
vertex_vat_country_code: NULL
  • BO result:
    image

@tweetyx
Copy link

tweetyx commented Mar 29, 2024

Hi,
for me the migration destroy link between entity_type_id in eav_entity_type with their attribute
so find in entity_type_id the customer_address entity id and default_attribute_set_id for me was 2 and 2

so look in eav_attribute table and find your customer attribute, look like :
"firstname" "middlename" "lastname" "suffix" "company" "street" "country_id" "region" etc
take their attribute Id and be sure the entity_type_id is the same as the customer_address entity id in entity_type_id
else edit and update attribute for that

and in final you must have in eav_attribute table the correspondance with attribute, for me they were delete in migration... so i take the data in my magento 1 database or
update the table like this

SET FOREIGN_KEY_CHECKS = 0; INSERT INTO eav_entity_attribute (entity_attribute_id, entity_type_id, attribute_set_id, attribute_group_id, attribute_id, sort_order) VALUES (9, 2, 2, 2, 9, 20), (4718, 2, 2, 2, 958, 134), (4717, 2, 2, 2, 957, 133), (4716, 2, 2, 2, 956, 132), (4715, 2, 2, 2, 955, 140); etc..
for exemple the first line "9" is my attribute "firstname" (find in eav_attribute) so we give
entity_attribute_id (just incremend id for table)
entity_type_id -> 2 -> the customer_address entity id
attribute_set_id -> 2 -> the default_attribute_set_id
attribute_group_id -> 2 -> the eav_attribute_group of customer address normaly -> (2, 2, 'General', 1, 1, 'general', NULL),
attribute_id -> 9 find in eav_attribute
sort_order -> 20 just for the beauty

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report Component: Sales Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed
Projects
None yet
Development

No branches or pull requests