I want to create a reference id for every order generated on my portal and show the same reference id on my shipping slip, I am using below code

$attribute  = array(
        'type'          => 'text',
        'backend_type'  => 'text',
        'frontend_input' => 'text',
        'is_user_defined' => true,
        'label'         => 'reference',
        'visible'       => true,
        'required'      => false,
        'user_defined'  => false,   
        'searchable'    => false,
        'filterable'    => false,
        'comparable'    => false,
        'default'       => ''
$installer->addAttribute('order', 'custom_reference', $attribute);

I will be thankful.


The Order entity is not EAV in Magento. So that code wouldn't work. You'd probably need to do something like this

        'type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
        'size' => 255,
        'nullable' => true,
        'comment' => 'custom reference'

This would add a new column to the sales_order table

|improve this answer|||||

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.