magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.5k stars 9.3k forks source link

Address Information not showing #5873

Closed ComputerNorth closed 6 years ago

ComputerNorth commented 8 years ago

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,

ziaur1 commented 6 years ago

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

Your problem will be solve...

nowsathyasar commented 6 years ago

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 commented 5 years ago

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

horebecommerce commented 5 years ago

@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 commented 5 years ago

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 commented 5 years ago

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

Anyone found solution for this?

hackronshins commented 5 years ago

I followed some solutions in git which they commented but no luck. I will update if I got any solution for this issue. If you know please let me know. Thanks & Regards jd prasad

On Fri, Jun 21, 2019 at 8:40 PM goutamfulcrum notifications@github.com wrote:

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

Anyone found solution for this?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/magento/magento2/issues/5873?email_source=notifications&email_token=AFSXCEK5D2QUI3DCWV4JAJDP3TVPRA5CNFSM4CK5AAF2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODYIXOFQ#issuecomment-504461078, or mute the thread https://github.com/notifications/unsubscribe-auth/AFSXCEOKTKVE4AXERUICBE3P3TVPRANCNFSM4CK5AAFQ .

-- VJD Prasad Director | Team Lead

102, Siri Sampada Hitex Building

Kavuri Hills, Madhapur, Hyd - 33 Contact No.: +91 9160310256 Facebook: www.facebook.com/jdprasadv | Linkedin: www.linkedin.com/jdprasadv

hackronshins commented 5 years ago

`<?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 commented 5 years ago

Any luck to anyone on this so far?

mikehenze commented 5 years ago

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

mak0605 commented 5 years ago

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_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;
`

**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 commented 5 years ago

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

eav_attributeas should be eav_attribute as (missing space)

mak0605 commented 5 years ago

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

mikehenze commented 5 years ago

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

mikehenze commented 5 years ago

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

oltskyi commented 5 years ago

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 commented 4 years ago

@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 commented 4 years ago

@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 commented 4 years ago

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

have you fixed this issue?

monak83 commented 3 years ago

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

WFEugenioCelant commented 1 year ago

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: test@test.com 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](https://user-images.githubusercontent.com/100704108/216325914-3bf6f02c-b4e2-489d-bc1c-f04ba3f26ade.png)
tweetyx commented 6 months ago

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