Jump to content

Cloning a module & making it work


Recommended Posts

I have found a custom module for Cash on delivery payment and I need it twice for having all payment possibilities I need. So i copied it, changed all names from XYZ to XYY - all files and all data in those files so there is no name XYZ in any document, it al contains the new XYY.

It works but if I make any changes in the XYZ module in BO of Prestashop it also makes changes in the XYY module like it was the same copy of the previous one.

 

Any idea on how to make it work separately? Thanks

Link to comment
Share on other sites

you will need to modify the cloned module to use other mysql and configuration values...not just here but in any file in the module folder.

	public function install()
	{  
        if (!parent::install() 
            OR !$this->registerHook('payment')
            OR !$this->registerHook('paymentReturn')  
            )
            return false;
     if((int)Configuration::get('PS_OS_PREPARATION'))
        return true;
  
     Db::getInstance()->autoExecuteWithNullValues('ps_order_state',$values,'INSERT');
             
             $lastid=Db::getInstance()->Insert_ID();
             if($lastid) {
                 Configuration::updateValue('COD_STATE', $lastid, 0, 0 );
                   $translations=array('cs'=>'V přípravě - dobírka'); 
                 $langs=Language::getLanguages();
                 foreach($langs as $lang) {
                   $name=isset($translations[$lang['iso_code']])?$translations[$lang['iso_code']]:'In preparation - COD';
                   $values=array(
                 'id_order_state'=>$lastid,
                  'id_lang'=>$lang['id_lang'],
                  'name'=>pSQL($name),
                  'template'=>pSQL($this->name), 
                 );
                  Db::getInstance()->AutoExecute('ps_order_state_lang',$values,'INSERT');
                 
                 }  
                 
           
             }  
   
	}
    

Link to comment
Share on other sites

Well OK, so I've found the part of code you've listed here... Between your replies I am trying to find all informations on how to solve this but nothing seems to help me to find out what exactly I should change.

 

I can't see anything that would suggest the used name or what part I should edit :-(

Link to comment
Share on other sites

So I've made a little bit of progress here. I found out that both the previous and the renamed module have separate numbers in my database. Is that something obvious or am I closer to solution?

 

I've read an article on how to write own modules so that I can digest as much knowledge as I can and I feel a bit wiser but still cannot make this thing work. Any help is greatly appreciated

Link to comment
Share on other sites

×
×
  • Create New...