0

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?

1
  • Useless comment - see edit in original article
    – Nautilus
    Commented Jul 23, 2015 at 8:28

2 Answers 2

1

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.

2
  • To be honest I don't know what would be the best way to approach this problem I guess the reason is that the attribute has to be a textbox that can be completed on every order. So we don't know the IMEI's before we create the order. I'm just not sure if this is possible with an attribute? And would we be able to open an order made in the past and see what IMEI was entered?
    – Nautilus
    Commented Jul 17, 2015 at 13:35
  • I think is the best solution. 1- You had like the same 100 phones, everyone have been imported with his IMEI in their attr, if anyone buys one, just put this attrib on the grid sales, and you could check by them. Maybe you could wait to other people if they think as me, or have a better solution.
    – ntzz
    Commented Jul 17, 2015 at 13:39
0

Attribute is a bad idea, because it should be correct for more than one product, imho. But you can add a custom option to it. The question is, how to add it in the backend, but you can do it the same way as in the frontend.

Creating a new column in sales_flat_order_item is the alternative and should be no problem either.

4
  • Thanks for the reply, but can I add custom options to "Simple Products"?
    – Nautilus
    Commented Jul 18, 2015 at 9:31
  • Sure you can do this. Commented Jul 18, 2015 at 9:53
  • I just added the custom option to a product and it works like a charm. Do you know of a way to copy this custom option to all my products? Kind regards
    – Nautilus
    Commented Jul 24, 2015 at 11:36
  • Magento doesn't allow this out of the box, but you can create them in code: magento.stackexchange.com/a/61247/217 Commented Jul 24, 2015 at 13:22

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.