Quick tip: Fixing the Prestashop slider (homeslider)

In this quick tip we will see how to fix the ‘unable to save settings’ issue concerning the Prestashop slider (homeslider)

Many users have reported not being able to save any kind of setting in the Prestashop slider configuration, using Prestashop 1.6. I decided to investigate the issue a bit further and found out it’s due to multiple entries in the ps_configuration table. How to deal with them? I tried modifying options myself, and here is what I came up with, ps_configuration table:

Prestashop Slider configuration issue

As you can see, the highlighted entries are duplicated, but represent the options I set for the slider. They read 1 under shop_id, while others all have NULL. It’s a total mess, considering this is what happens right after resetting the module. So, being the entries there, why are they not displaying, or have any effect? It’s due to the shop id.

The cleanest way is to re-gain access to the back office configuration, by modifying the homeslider.php file directly. First, we need to re-gain control in the front office. Open homeslider.php located at modules/homeslider, then find the following:

		$slider = array(
			'width' => Configuration::get('HOMESLIDER_WIDTH'),
			'speed' => Configuration::get('HOMESLIDER_SPEED'),
			'pause' => Configuration::get('HOMESLIDER_PAUSE'),
			'loop' => (bool)Configuration::get('HOMESLIDER_LOOP'),
		);

As you can see, there is no reference to any shop id or group, and that causes the configuration table to return the first entry matching that name. Let’s add both:

		$slider = array(
			'width' => Configuration::get('HOMESLIDER_WIDTH', null, $this->context->shop->getGroup(), $this->context->shop->id),
			'speed' => Configuration::get('HOMESLIDER_SPEED', null, $this->context->shop->getGroup(), $this->context->shop->id),
			'pause' => Configuration::get('HOMESLIDER_PAUSE', null, $this->context->shop->getGroup(), $this->context->shop->id),
			'loop' => (bool)Configuration::get('HOMESLIDER_LOOP', null, $this->context->shop->getGroup(), $this->context->shop->id),
		);

Save and test the front office, it should be reflecting the latest changes. That said, our back office still displays wrong values. If it’s not a big deal for you, you can simply get away with the previous fix only.

But if you really care about the back office values, then there is another method to amend: getConfigFieldsValues. Locate the following:

		return array(
			'HOMESLIDER_WIDTH' => Tools::getValue('HOMESLIDER_WIDTH', Configuration::get('HOMESLIDER_WIDTH')),
			'HOMESLIDER_SPEED' => Tools::getValue('HOMESLIDER_SPEED', Configuration::get('HOMESLIDER_SPEED')),
			'HOMESLIDER_PAUSE' => Tools::getValue('HOMESLIDER_PAUSE', Configuration::get('HOMESLIDER_PAUSE')),
			'HOMESLIDER_LOOP' => Tools::getValue('HOMESLIDER_LOOP', Configuration::get('HOMESLIDER_LOOP')),
		);

You will notice there is a default value there, which should reflect the last submitted one, so why is it not displaying? Because, “smartly”, the page is refreshing after updating the slider options. Therefore, let’s apply the same fix we used above:

		return array(
			'HOMESLIDER_WIDTH' => Tools::getValue('HOMESLIDER_WIDTH', Configuration::get('HOMESLIDER_WIDTH', null, $this->context->shop->getGroup(), $this->context->shop->id)),
			'HOMESLIDER_SPEED' => Tools::getValue('HOMESLIDER_SPEED', Configuration::get('HOMESLIDER_SPEED', null, $this->context->shop->getGroup(), $this->context->shop->id)),
			'HOMESLIDER_PAUSE' => Tools::getValue('HOMESLIDER_PAUSE', Configuration::get('HOMESLIDER_PAUSE', null, $this->context->shop->getGroup(), $this->context->shop->id)),
			'HOMESLIDER_LOOP' => Tools::getValue('HOMESLIDER_LOOP', Configuration::get('HOMESLIDER_LOOP', null, $this->context->shop->getGroup(), $this->context->shop->id)),
		);

And that settles it!

Prestashop slider configuration issue fixed

You like the tuts and want to say "thank you"? Well, you can always feel free to donate:

  • Benito Juárez

    you rock dude

  • Diego Montoya

    Good and clean solution.

    What I did to solve this problem was to modify the value directly in mysql, even it’s not the best solution, I did it because this parameter don’t change very often.

    In addition something to consider for doing what the post says is that in new upgrades this changes will be lost

Store Top Sales

You like the tuts and want to say "thank you"? Well, you can always feel free to donate: