0

I know people already tried to delete the SKU field in the email confirmation field. But I want to something different.

I managed to change the SKU field in "my account" by copying the template as mentioned here https://stackoverflow.com/questions/13017942/magento-delete-sku-from-order-email and it worked out great.

Now I was thinking to do the same for the new order confirmation email. I managed to change the column field name and tried to change the default getSku with $_item->getData('mpn'); but it stays empty no matter what.

1 Answer 1

0

I'm going to assume that mpn is a custom product attribute. The reason why nothing shows up when you call $_item->getData('mpn'); is because that column does not exist in sales_flat_order_item table so there is no data to return.

First you need to add mpn column to sales_flat_quote_item and sales_flat_order_item tables. For that you need to create a custom module with setup script.

$installer = $this;
$installer->startSetup();

$installer->getConnection()
    ->addColumn($installer->getTable('sales/quote_item'), 'mpn', array(
        'type'      => Varien_Db_Ddl_Table::TYPE_TEXT,
        'lenght'    => 255,
        'comment'   => 'MPN'
    ));

$installer->getConnection()
    ->addColumn($installer->getTable('sales/order_item'), 'mpn', array(
        'type'      => Varien_Db_Ddl_Table::TYPE_TEXT,
        'lenght'    => 255,
        'comment'   => 'MPN'
    ));

$installer->endSetup();

Next you need to instruct Magento to copy your custom attribute value to quote item table, and once quote is converted to order, to order item table rows we just created. Add this to your config.xml file under <global> node.

<sales>
    <quote>
        <item>
            <product_attributes>
                <mpn/>
            </product_attributes>
        </item>
    </quote>
</sales>

<fieldsets>
    <sales_convert_quote_item>
        <mpn>
            <to_order_item>*</to_order_item>
        </mpn>
    </sales_convert_quote_item>
</fieldsets>

That's it. Now you can call $_item->getData('mpn'); in your email template. Please note that it will work only for new orders.

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.