Jump to content

[SOLVED]Duplicate module Editorial in Prestashop 1.4


seelk

Recommended Posts

Hello,

 

i`d like to duplicate module Editorial.

 

Copy the existing module and rename to it for new name:

From: editorial to:editorial2

 

Next:

 

Change related file name to a different ones:

From: editorial.php To: editorial2.php

From: editorial.tpl To:editorial2.tpl

From EditorialClass.php To: EditorialClass2.php

 

Change name in xml file:


editorial
...

 

 

To:

 



editorial
...

 

 

In the new file editorial2.php change to:

 

class Editorial2 extends Module

$this->name = 'editorial2';

include_once($path.'/EditorialClass2.php');

if (!Db::getInstance()->Execute('
	CREATE TABLE `'._DB_PREFIX_.'editorial2` (
	`id_editorial` int(10) unsigned NOT NULL auto_increment,
	`body_home_logo_link` varchar(255) NOT NULL,
	PRIMARY KEY (`id_editorial`))
	ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8'))
		return false;

if (!Db::getInstance()->Execute('
	CREATE TABLE `'._DB_PREFIX_.'editorial_lang2` (
	`id_editorial` int(10) unsigned NOT NULL,
	`id_lang` int(10) unsigned NOT NULL,
	`body_title` varchar(255) NOT NULL,
	`body_subheading` varchar(255) NOT NULL,
	`body_paragraph` text NOT NULL,
	`body_logo_subheading` varchar(255) NOT NULL,
	PRIMARY KEY (`id_editorial`, `id_lang`))
	ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8'))
		return false;

$editorial = new EditorialClass2(1);

Configuration::updateValue('EDITORIAL2_IMAGE_WIDTH', (int)round($width));
Configuration::updateValue('EDITORIAL2_IMAGE_HEIGHT', (int)round($height));
Configuration::updateValue('EDITORIAL2_IMAGE_DISABLE', 0);

public function hookHome($params)
{
	global $cookie, $smarty;


	$editorial = new EditorialClass2(1, (int)$cookie->id_lang);
	$smarty->assign(array(
		'editorial2' => $editorial,
		'default_lang' => (int)$cookie->id_lang,
		'image_width' => Configuration::get('EDITORIAL2_IMAGE_WIDTH'),
		'image_height' => Configuration::get('EDITORIAL2_IMAGE_HEIGHT'),
		'id_lang' => $cookie->id_lang,
		'homepage_logo' => !Configuration::get('EDITORIAL2_IMAGE_DISABLE') && file_exists('modules/editorial2/homepage_logo.jpg'),
		'image_path' => $this->_path.'homepage_logo.jpg'
	));
	return $this->display(__FILE__, 'editorial2.tpl');
}

 

I changed the name of the base tables in every place.

 

 

In the file EditorialClass2.php i changed

class		EditorialClass2 extends ObjectModel

protected	 $table = 'editorial2';

 

When i changed parametr $tabel to 'editorial' i get content from orginial module Editorial.

 

I do not know what else should be changed to retrieve the contents of the table editorial_lang2 and editorial2 in my duplicate module editorial2?

Link to comment
Share on other sites

I think the problem is the name of the new lang table.  try changing the create table statements

 

from

CREATE TABLE `'._DB_PREFIX_.'editorial_lang2` (

 

to

CREATE TABLE `'._DB_PREFIX_.'editorial2_lang` (

 

to test it, you can just use phpmyadmin to change the table name first.

 

Link to comment
Share on other sites

  • 1 month later...

Unfortunately, I have a problem with duplication of the module. We managed to save the changes made ​​to the database in the admin panel, but they are not display in the shop, only the contents of the original module.

Additionally, if I turn the duplicated module, and then turn off the original does not appear in any of them.

 

I attach the configuration files.

EditorialClass2.php

editorial2.php

Link to comment
Share on other sites

  • 6 months later...

When i attempt to create a duplicate text module it just shows up on the module list identical to the other one so when i try to install, it says that module is already installed. Any idea why it's showing up the same even though the text module is edited and saved to say two, 2 on everything etc.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...