Magento2: Custom attribute(Customer Address type) not saved when Create New Order from admin

Created on 7 Sep 2017  路  7Comments  路  Source: magento/magento2


Preconditions


  1. Magento 2.1.7
  2. Identified on PHP 7.0.9-1

Steps to reproduce

  1. Create Customer address attribute using installdata script as below:
    `$customerSetup = $this->customerSetupFactory->create(['setup' => $setup]);
    $customerSetup->addAttribute('customer_address', 'suburb', [
        'label' => 'Suburb',
        'input' => 'text',
        'type' => 'varchar',
        'source' => '',
        'required' => true,
        'position' => 70,
        'visible' => true,
        'system' => false,
        'is_used_in_grid' => false,
        'is_visible_in_grid' => false,
        'is_filterable_in_grid' => false,
        'is_searchable_in_grid' => false,
        'backend' => ''
    ]);


    $attribute = $customerSetup->getEavConfig()->getAttribute('customer_address', 'suburb')
        ->addData(['used_in_forms' => [
            'adminhtml_customer_address',
            'customer_address_edit',
            'customer_register_address'
        ]]);
    $attribute->save();`

  1. Open Admin >> Sales >> Order >> Create New Order
  2. Select Store >> Address Information >> Fill address with our Custom attribute(Suburb)
  3. Select Payment Method and Shipping Method
  4. Submit Order

Expected result

  1. Suburb should be saved same as other customer address attributes
  2. As we have already filled value in Custom attribute field(Suburb) It should not generate any required field value PHP error.
  3. Even if We have already save value in Customer >> Address then It must be visible on Create new Order >> Billing Address/ Shipping Address form

Actual result


  1. new order orders operations sales magento admin

  2. new order orders operations sales magento admin 1
  1. Value not saved while other attributes saved and retrieved as well.
Customer Confirmed P4 ready for dev Reproduced on 2.2.x Reproduced on 2.3.x S4 help wanted

Most helpful comment

@ronakChauhanKrish thank you for your bug report.
We've created internal ticket MAGETWO-75304 to track progress on the issue

All 7 comments

im on it

It is not saved, because order address values are stored in "quote_address" and "sales_order_address" tables. By creating new customer address attribute, columns are not automatically created in the above tables.
There are more steps to add new address attribute in correct way:

  1. create customer address attribute
  2. create new columns in quote_address and sales_order_address:
$salesSetup = $this->salesSetupFactory->create(['setup' => $setup]);
$salesSetup->addAttribute('order_address', 'suburb', ['type' => 'text']);
$quoteSetup = $this->quoteSetupFactory->create(['setup' => $setup]);
$quoteSetup->addAttribute('quote_address', 'suburb', ['type' => 'text']);
  1. add fieldset in xml file to copy new field value from quote address to order address
<fieldset id="sales_convert_quote_address">
     <field name="suburb">
          <aspect name="to_order_address" />
     </field>
</fieldset>
  1. create new setter method in order address class:
public function setSuburb($suburb)
{
     return $this->setData('suburb', $suburb);
}

@ronakChauhanKrish thank you for your bug report.
We've created internal ticket MAGETWO-75304 to track progress on the issue

I am working on it at #mm17es

Reproduced the same error in Magento 2.2.1 with PHP 7.0.25

Hi @engcom-backlog-nazar. Thank you for working on this issue.
Looks like this issue is already verified and confirmed. But if your want to validate it one more time, please, go though the following instruction:

  • [x] 1. Add/Edit Component: XXXXX label(s) to the ticket, indicating the components it may be related to.
  • [x] 2. Verify that the issue is reproducible on 2.3-develop branch

    Details- Add the comment @magento-engcom-team 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_!

  • [x] 3. Verify that the issue is reproducible on 2.2-develop branch.

    Details- Add the comment @magento-engcom-team 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

  • [ ] 4. If the issue is not relevant or is not reproducible any more, feel free to close it.

@engcom-backlog-nazar Thank you for verifying the issue. Based on the provided information internal tickets MAGETWO-97682, MAGETWO-97683 were created

Was this page helpful?
0 / 5 - 0 ratings