0

I want to change the default SKU attribute (product number) inside the orderview, at the items block, to a custom attribute.

See:

enter image description here

Currently by default the SKU is displayed, I want to change this into the DPN (my custom created attribute).

The attribute code for this is: dpn.

How can I achieve that?

I edit the file:

/app/code/core/Mage/Adminhtml/Block/Sales/Items/Column/Default.php

From default code:

public function getSku()
{
    /*if ($this->getItem()->getProductType() == Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE) {
        return $this->getItem()->getProductOptionByCode('simple_sku');
    }*/
    return $this->getItem()->getSku();
}

To:

public function getSku()
{
    /*if ($this->getItem()->getProductType() == Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE) {
        return $this->getItem()->getProductOptionByCode('simple_sku');
    }*/
    return $this->getItem()->getDpn();
}

But that does not work. When I change the value to return $this->getItem()->getProductId(); Then I get the Product Id, so that does work.

How can I get the data from the attribute?

2 Answers 2

0

To change 'name' column in Order View -> Items Ordered in Magento Admin:

1) Add layout update:

<adminhtml_sales_order_view>
    <reference name="order_items">
        <action method="addColumnRender">
            <column>name</column>
            <block>adminhtml/sales_items_column_name</block>
            <template>neklo_custom/sales/items/column/name.phtml</template>
        </action>
    </reference>
</adminhtml_sales_order_view>

2) Copy template from app/design/adminhtml/default/default/template/sales/items/column/name.phtml

to app/design/adminhtml/default/default/template/neklo_custom/sales/items/column/name.phtml

3) Change template content output

4
  • Thanks for your reply. But I do not want to change the name. I want to change the SKU attribute inside an order. How can I change the displayed attribute?
    – JGeer
    Aug 9, 2016 at 6:22
  • Change output inside the 'Items Ordered' block on 'Order View' page in backend? E.g. Gym Bag SKU: free-gym-bag, Size: One Color: Black change to Gym Bag MPN: mpn_example, Size: One Color: Black ?
    – Neklo.com
    Aug 9, 2016 at 17:49
  • Thanks for the reply. That is exactly what I mean. How can I achieve that?
    – JGeer
    Aug 10, 2016 at 6:26
  • See my edit, will that be a good solution?
    – JGeer
    Aug 10, 2016 at 10:20
0

I solved the problem.

The good solutions was:

public function getSku()
{
    /*if ($this->getItem()->getProductType() == Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE) {
        return $this->getItem()->getProductOptionByCode('simple_sku');
    }*/
    return Mage::getResourceModel('catalog/product')->getAttributeRawValue($this->getItem()->getProductId(), 'dpn');
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.