Jump to content

Need add images to Attribute Generator


daxdax2

Recommended Posts

Hi.  I need to add to Attribute Generator images from product. 
 
WHY? 
Because when I generate 38 combination of sport wear, like size 29-36 with 4 colors and Now I need enter in each combination for set two images that first it is standard image of wear 
and second is a wear in color. 
it would save a lot of time if I can check the images when create combination.
 
I know what controller generating combination in (controllers\admin\AdminAttributeGeneratorController.php), and I want override it by creaTING a module. 
Module I create, and copy file to modules\combinationimages\override\controllers\admin\AdminAttributeGeneratorController.php 
 
change class to 
 
class AdminAttributeGeneratorController extends AdminAttributeGeneratorControllerCore
 
specifically made ​​a syntax error, but file not loaded when I enable module.
 
What I want doing in attache image


my module
<?php
/**
 * Created by PhpStorm.
 * User: man
 * Date: 19.08.14
 * Time: 9:26
 */
	if (!defined('_PS_VERSION_'))
		exit;
	class CombinationImages extends Module
	{
		public function __construct()
		{
			echo '<PRE>';
			print_r($this->tab);
			echo '</pre>';
			$this->name = 'combinationimages';
			$this->tab = 'content_management';
			$this->version = '1.0';
			$this->author = 'Dax Axe';
			$this->need_instance = 1;
			$this->ps_versions_compliancy = array('min' => '1.5', 'max' => '1.6');
			$this->bootstrap = true;
			$this->controllers = array('attributeGenerator');

			parent::__construct();

			$this->displayName = $this->l('Combination Images');
			$this->description = $this->l('Add images to combination generator.');

			$this->confirmUninstall = $this->l('Are you sure you want to uninstall?');

			if (!Configuration::get('MYMODULE_NAME'))
				$this->warning = $this->l('No name provided');
		}

		public function install()
		{
			if (Shop::isFeatureActive())
				Shop::setContext(Shop::CONTEXT_ALL);

			if (!parent::install() ||
				!$this->registerHook('updateProductAttribute') ||
				!$this->registerHook('displayBackOfficeHeader')||
				!Configuration::updateValue('COMBINATION_SHOW_IMAGES', '1')
			)
				return false;

			return true;
		}

		public function uninstall()
		{
			if (!parent::uninstall() ||
				!Configuration::deleteByName('COMBINATION_SHOW_IMAGES')
			)
				return false;

			return true;
		}

		public function getContent()
		{
			$output = null;

			if (Tools::isSubmit('submit'.$this->name))
			{
				$combination_show_images = strval(Tools::getValue('COMBINATION_SHOW_IMAGES'));
				if (!$combination_show_images
					|| empty($combination_show_images)
					|| !Validate::isBool($combination_show_images))
					$output .= $this->displayError($this->l('Invalid Configuration value'));
				else
				{
					Configuration::updateValue('COMBINATION_SHOW_IMAGES', $combination_show_images);
					$output .= $this->displayConfirmation($this->l('Settings updated'));
				}
			}
			return $output.$this->displayForm();
		}

		public function displayForm()
		{
			// Get default language
			$default_lang = (int)Configuration::get('PS_LANG_DEFAULT');

			// Init Fields form array
			$fields_form[0]['form'] = array(
				'legend' => array(
					'title' => $this->l('Settings'),
				),
				'input' => array(
					array(
						'type' => 'radio',
						'label' => $this->l('Configuration value'),
						'name' => 'COMBINATION_SHOW_IMAGES',
						'size' => 1,
						'required' => true,
						'values' => array(
							array(
								'id' => 'show',
								'value' => 0,
								'label' => $this->l('On')
							),
							array(
								'id' => 'not_show',
								'value' => 1,
								'label' => $this->l('Off')
							),
						)
					)
				),
				'submit' => array(
					'title' => $this->l('Save'),
					'class' => 'button'
				)
			);

			$helper = new HelperForm();

			// Module, token and currentIndex
			$helper->module = $this;
			$helper->name_controller = $this->name;
			$helper->token = Tools::getAdminTokenLite('AdminModules');
			$helper->currentIndex = AdminController::$currentIndex.'&configure='.$this->name;

			// Language
			$helper->default_form_language = $default_lang;
			$helper->allow_employee_form_lang = $default_lang;

			// Title and toolbar
			$helper->title = $this->displayName;
			$helper->show_toolbar = true;        // false -> remove toolbar
			$helper->toolbar_scroll = true;      // yes - > Toolbar is always visible on the top of the screen.
			$helper->submit_action = 'submit'.$this->name;
			$helper->toolbar_btn = array(
				'save' =>
					array(
						'desc' => $this->l('Save'),
						'href' => AdminController::$currentIndex.'&configure='.$this->name.'&save'.$this->name.
							'&token='.Tools::getAdminTokenLite('AdminModules'),
					),
				'back' => array(
					'href' => AdminController::$currentIndex.'&token='.Tools::getAdminTokenLite('AdminModules'),
					'desc' => $this->l('Back to list')
				)
			);

			// Load current value
			$helper->fields_value['COMBINATION_SHOW_IMAGES'] = Configuration::get('COMBINATION_SHOW_IMAGES');

			return $helper->generateForm($fields_form);
		}

	}
 

 

post-403334-0-98306500-1408446581_thumb.jpg

Link to comment
Share on other sites

  • 5 months later...
  • 1 year later...

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...