Magento – Custom Magento Module IMEI / Serial number with products

magento-1.8moduleorders

I need a module that is able to attach a serialnumber/IMEI number to each product sold. We sell a lot of cellphones and the IMEI is necessary for the warranty of a device.

I noticed a number of people are searching for a solution like this but I couldn't find a decent one. So I would like to create one, but I do need some help, I'm not a really experienced programmer!

I would like to change the "magentostore.url/admin/sales_order_create/" page like this:
enter image description here

So there is simply another text field on each products line where the seller can enter the IMEI code. This only needs to be in the adminhtml.

So as far as I know:

  • I need to define a module (lets call it TSC_Serialnumbers)

  • I need a way to overwrite app\design\adminhtml\default\default\template\sales\order\create\items\grid.phtml

  • And I need a way to save the entered values so they can be used in; invoice, ordermail, etc.

If lets say a customer loses his invoice we should be able to retreive it after a few months and print it again.

My goal is to create a fully functioning module and place it on Magento Connect FOR FREE! Any help is greatly appreciated and I will give everybody credit who help out!

EDIT 17/07:

Meanwhile I have been busy trying to create a module: So far I got this, please correct me if I'm wrong! I started this with the http://www.silksoftware.com/magento-module-creator/

My config.xml:

<?xml version="1.0"?>
<config>
  <modules>
    <TSC_Serialnumbers>
      <version>0.1.0</version>
    </TSC_Serialnumbers>
  </modules>
  <global>
    <helpers>
      <serialnumbers>
        <class>TSC_Serialnumbers_Helper</class>
      </serialnumbers>
    </helpers>
    <models>
      <serialnumbers>
        <class>TSC_Serialnumbers_Model</class>
        <resourceModel>serialnumbers_mysql4</resourceModel>
      </serialnumbers>
    </models>
    <resources>
      <salesattribute1437139568_setup>
        <setup>
          <module>TSC_Serialnumbers</module>
          <class>Mage_Sales_Model_Mysql4_Setup</class>
        </setup>
        <connection>
          <use>core_setup</use>
        </connection>
      </salesattribute1437139568_setup>
      <salesattribute1437139568_write>
        <connection>
          <use>core_write</use>
        </connection>
      </salesattribute1437139568_write>
      <salesattribute1437139568_read>
        <connection>
          <use>core_read</use>
        </connection>
      </salesattribute1437139568_read>
    </resources>
  </global>
</config> 

and sql\salesattribute1437139568_setup\mysql4-install-0.1.0.php

<?php
$installer = $this;
$installer->startSetup();

$installer->addAttribute("order_item", "serialnumber", array("type"=>"varchar"));
$installer->endSetup();

EDIT 23/07/2015

Ok, I'm going to try it using custom options like @Fabian Blechschmidt suggested, But I still have no clue on how to begin.

As I read I need to use this code

$existentOptions = $orderItem->getProductOptions();
if (!isset($existentOptions['additional_options'])) {
    // If special options of options array is set before, create it.
    $existentOptions['additional_options'] = array(); 
}
// Adding visible options value
$existentOptions['additional_options'][] = array(
    'label' => 'Your Option Label',
    'value' => 'Your Option Value',
    // The last one that is optional (if not set, value is used)
    'print_value' => 'Your Option Value shown in printed documents'
);
$orderItem->setProductOptions($existentOptions);

Do I need to start writing a new module for this?

How can I change the contents of app\design\adminhtml\default\default\template\sales\order\create\items\grid.phtml without overwriting core files?

Best Answer

And my question is... Why you don't create an attribute for the IMEI. Then change the grid on the adminhtml to show IMEI on it.

With it, you could display it where you want easily.

In addition, you don't have to make a lot of code, and its more functionality for cron jobs or imports.

Related Topic