I am using custom module Cash on delivery restriction by zipcodes for Magento

enter image description here I am having an issue to add pincodes more than 10 thousand. This module only accepts 8 thousand pincodes.

here is Observer class

class Mfp_Cod_Model_Observer
    public function getCashOnDelvery(Varien_Event_Observer $observer)
        $event           = $observer->getEvent();
        $method          = $event->getMethodInstance();
        $result          = $event->getResult();
        $isModuleEnable  = Mage::getStoreConfig('cod/cod/enable');

        if ($isModuleEnable) {
            if ($method->getCode() == 'phoenix_cashondelivery' ) {
                $quote          = Mage::getSingleton('checkout/cart')->getQuote();
                $add            = $quote->getShippingAddress();
                $postcode       = $add->getData('postcode');
                $comparisonMode = Mage::getStoreConfig('cod/cod/mode');
                $zipCodes       = Mage::getStoreConfig('cod/cod/zipcode');
                $isExist        = false;

                if (trim($zipCodes) == '') {
                    $result->isAvailable = true;
                } else {
                    if (strpos($zipCodes, $postcode) !==  false) {
                        $isExist = true;

                    if ($isExist != true) {
                        $zipCodesArray = explode(',', nl2br($zipCodes));
                        if (count($elementLineArray) > 1) {
                            foreach ($zipCodesArray as $codzipLine) {
                                $elementLineArray = explode('-', $codzipLine);
                                if (count($elementLineArray) == 2 && ( $postcode >= $elementLineArray[0] && $postcode <= $elementLineArray[1] )) {
                                    $isExist = true;
                                } else if ($postcode == $codzipLine) {
                                    $isExist = true;

                    $returnValue = '';
                    $returnValue = ($isExist)?true:false;

                    $result->isAvailable = $returnValue;

can anyone help me to resolve this issue. is there any limitation for data saving. How can I add more than 10 thousand zipcodes?

4 Answers 4


I would not change the column tpye to LONGTEXT for core_config_data table, because it could have a negative impact on performance.

If I had to save such a large number of zipcode I would

  • add a new DB table cod_zipcodes and
  • a new admin grid to maintain them.

It's bit more work then adding a new config field, but you dont have alter DB structure and in your observer you just have to check if the zipcode exists in your table, instead of iterating over an 10k size array.

  • This approach is good. I like to hear your comment on my approach. Commented Mar 6, 2018 at 6:54
  • @KalyanChakravarthiV it would be my 2nd choice :) If you want to manage it from backend or config you also have to add a source model. So there is still some additional work ... +1 ;)
    – sv3n
    Commented Mar 6, 2018 at 9:36
  • Thanks for the comment :) yes additional work is required but it's a reliable solution isn't it ? If there is anything wrong in that approach I request to correct it. Based on that I can suggest or don't recommend it as a solution to others Commented Mar 6, 2018 at 9:39
  • @KalyanChakravarthiV Haven't tested it, but i think there is nothing wrong with your approach. :)
    – sv3n
    Commented Mar 6, 2018 at 9:47

Instead of saving the pincodes in the database, I suggest using a file to save all your pincodes. It can be CSV file or XML file or JSON file. You can use respective handler based on the file format. In your observer read the file and extract the values and compare. This way there is no need to do any DB level changes.

In admin settings, in the place of Zipcodes keep the file upload option.

Here is an example to read XML file from the source ( http://blog.chapagain.com.np/magento-read-write-xml/ )

$xmlPath = Mage::getBaseDir().DS.'test.xml';
$xmlObj = new Varien_Simplexml_Config($xmlPath);
$xmlData = $xmlObj->getNode();
echo "<pre>"; print_r($xmlData); echo "</pre>";

If your core_config_data database table value column is having "text" datatype, you need to alter the table.

ALTER TABLE core_config_data MODIFY value MEDIUMTEXT; (It will store 16,777,215 - 16 MB)


ALTER TABLE core_config_data MODIFY value LONGTEXT; (It will store 4,294,967,295 characters - 4 GB)

Hope this will help you.


I Think there are no issues on code maybe it's executed max_input_vars. You just need to open your server's php.ini file with root user, search for max_input_vars and set its value as 100000 and it will solve your problem.

max_input_vars = 100000

I hope it'll help you to resolve your problem.


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.