Jump to content

Tried to uninstall and then delete Specials Block module but it won't delete?


5haun

Recommended Posts

Hi Guys

 

Here's a screenshot of the module after I uninstalled it and deleted it:

 

E0mPOgc.jpg

Once deleted it says "Module deleted successfully."
BUT
Still showing there after selecting delete, also the module thumbnail background turned black? Really weird
Please help me find a solution! I need to go live on the website soon.

Edited by 5haun (see edit history)
Link to comment
Share on other sites

Have a link for us?

Expect some caching problem. Can you turn on enforce compile and cache off in Advanced Parameters for a moment and see if that helps?

 

pascal

 

 

free modules signed "by prestashop"  are official modules included to each installation,

you can't remove them from back office at all,

they will appear there even if you will uninstall them

 

Thanks for the replies guys :)

 

I was actually hoping If I completely delete the module and then reinstall it, it would fix the problem I am having.

 

The problem I am having is that I have the block set to displayRightColumn but it is only showing 1 product. I have set it to display 4 in the configuration...

 

Is there a way to fix this? v1.6.0.9

Link to comment
Share on other sites

Hi 5haun,

 

In the configuration screen, you don't put the AMOUNT of products it will show, but the number of products it will cache, so that it can quickly choose from this subgroup when rendering or refreshing a page. ((if for example you put the number of cached files to 4, it caches four products and it will only choose from these four to display. (This is done to speed up the selection of a specials product, as it may take some considerable computer time to find out which product is a specials one.)

 

At the moment, the module always shows just 1 product, with a link to the bottom of the specials block where you can go to a page with all specials.

 

To really show the amount of products you want (4), you have to change the code of the module a little.

 

I'll try to show you with help of code PS 1.6.0.9:

 

Edit file /module/blockspecials/blockspecials.php (Make backup! Or even better,make an override. I leave that as an exercise for you)

 

Find the function:

	public function hookRightColumn($params)
	{
		if (Configuration::get('PS_CATALOG_MODE'))
			return;
		
		// We need to create multiple caches because the products are sorted randomly
		$random = date('Ymd').'|'.round(rand(1, max(Configuration::get('BLOCKSPECIALS_NB_CACHES'), 1)));

		if (!Configuration::get('BLOCKSPECIALS_NB_CACHES') || !$this->isCached('blockspecials.tpl', $this->getCacheId('blockspecials|'.$random)))
		{
			if (!($special = Product::getRandomSpecial((int)$params['cookie']->id_lang)) && !Configuration::get('PS_BLOCK_SPECIALS_DISPLAY'))
				return;

			$this->smarty->assign(array(
				'special' => $special,
				'priceWithoutReduction_tax_excl' => Tools::ps_round($special['price_without_reduction'], 2),
				'mediumSize' => Image::getSize(ImageType::getFormatedName('medium')),
			));
		}

		return $this->display(__FILE__, 'blockspecials.tpl', (Configuration::get('BLOCKSPECIALS_NB_CACHES') ? $this->getCacheId('blockspecials|'.$random) : null));
	}

Somewhere in the middle, you see the line where the special product is fetched:

$special = Product::getRandomSpecial((int)$params['cookie']->id_lang)

 

This is a function from the file classes/Product.php.

It will only return one single product that has a special (i.e. discounted) price. 

 

Because you want 4 products, we have to use another function to get more results. Lucky for us, Product.php already has one that we can use:

public static function getPricesDrop($id_lang, $page_number = 0, $nb_products = 10, $count = false,
$order_by = null, $order_way = null, $beginning = false, $ending = false, Context $context = null)
 

So, we need to change the function call to this new function, and limit the amount to the one you wanted (4):

 

$specials = Product::getPricesDrop((int)$params['cookie']->id_lang,0,4)

 

As you can see, I changed the variable name into its plural: $specials, as we have now more special products :-)

 

We do have to incorporate this new situation in the tpl file (the file that builds the html block to show). Therefore we have to change the smarty 'special' into 'specials' as well:

 

$this->smarty->assign(array(
    'specials' => $specials,
    'priceWithoutReduction_tax_excl' => Tools::ps_round($special['price_without_reduction'], 2),
    'mediumSize' => Image::getSize(ImageType::getFormatedName('medium')),
));
 

Only one problem remains, that is the original price is also shown in the special block (the price with a strike through line). In the original code, this was done in the line

 

    'priceWithoutReduction_tax_excl' => Tools::ps_round($special['price_without_reduction'], 2),
 
But this we cannot use anymore, as we have now more than one product. Therefore we need to add a little code to add all unreduced, original prices so we can show them all.
 
To do that, we quickly go over the selected products, and add this same function result for each product to the $specials array itself, for convenience's sake. We add this code just after getting the specials products:
 
if (!($specials = Product::getPricesDrop((int)$params['cookie']->id_lang,0,4)) &&
        !Configuration::get('PS_BLOCK_SPECIALS_DISPLAY'))
    return;
foreach ($specials as &$special)
    $special['price_without_reduction_rounded'] = Tools::ps_round($special['price_without_reduction'], 2);
 
What we do is, we add a new element 'price_without_reduction_rounded' to each $special array (Note not $specials!, each array in $specials we call $special for the moment), which contains the rounded value of the 'price_without_reduction' element (This way we don't have to round off in the smarty template anymore, which is much slower)
 
The last thing we do here is take out the redundant line (because it only had one single original price instead of of all selected products, remember?)
 
//    'priceWithoutReduction_tax_excl' => Tools::ps_round($special['price_without_reduction'], 2),
 
By adding some comment code '//' at the front 
 
In total, we get this function:
 
public function hookRightColumn($params)
{
   if (Configuration::get('PS_CATALOG_MODE'))
      return;
 
   // We need to create multiple caches because the products are sorted randomly
   $random = date('Ymd').'|'.round(rand(1, max(Configuration::get('BLOCKSPECIALS_NB_CACHES'), 1)));
 
   if (!Configuration::get('BLOCKSPECIALS_NB_CACHES') || !$this->isCached('blockspecials.tpl',
         $this->getCacheId('blockspecials|'.$random)))
   {
      if (!($specials = Product::getPricesDrop((int)$params['cookie']->id_lang,0,4)) &&
            !Configuration::get('PS_BLOCK_SPECIALS_DISPLAY'))
         return;
      foreach ($specials as &$special)
         $special['price_without_reduction_rounded'] =
               Tools::ps_round($special['price_without_reduction'], 2);
 
      $this->smarty->assign(array(
            'specials' => $specials,
         // 'priceWithoutReduction_tax_excl' => Tools::ps_round($special['price_without_reduction'], 2),
            'mediumSize' => Image::getSize(ImageType::getFormatedName('medium')),
      ));
   }
 
   return $this->display(__FILE__, 'blockspecials.tpl', (Configuration::get('BLOCKSPECIALS_NB_CACHES') ?          $this->getCacheId('blockspecials|'.$random) : null));
}
 
And (Did you make a backup???) save the file.
 
Well, long story for not too much changes, actually,, but I wanted to explain it clearly what I did...
 
The second file we need to change:
 
We need to change the smarty template file: themes/<your theme folder>/modules/blockspecials/blockspecials.tpl  (Make backup!!!)
 
in here you see the original $special (with only one product in it), which we will change to $specials
 
<div class="block_content products-block">
    {if $specials}
 
(Add the red s)
 
Next thing we need to do is making the code go through ALL product now. We add the foreach command:
 
{if $specials}
   <ul>
      {foreach from=$specials item='special'}
        <li class="clearfix">
 
We see that we go though all elements of $specials and call each item we work on $special, (just like it was before). This way, we can use the old code as it is :-)
 
Of course we need to tell where the en of the foreach loop is. Scroll down until you see tis code and add the red line:
 
         </li>
      {/foreach}
   </ul>
<div>
<a class="btn btn-default button button-small" 
 
As you see, all products will be separate <li>'s (listed elements). 
 
 
No we only need to change the code where we get the original price, as we changed the variable where these are stored to :
    $special.price_without_reduction_rounded
 
So, let's change the original variable ( {$priceWithoutReduction_tax_excl}  ) to this one:
 
<span class="old-price">
   {if !$priceDisplay}
      {displayWtPrice p=$special.price_without_reduction}
   {else}
      {displayWtPrice p=$special.price_without_reduction_rounded}
   {/if}
</span>
 
 
Then (Did you backup the file??) save the file.
 
Reload the page  (temporarily turn off smarty cache and set force compilation to ON in Advanced Parameters->Optimization to see the effect)
 
And you should see this (sorry, I had only 2 special products define, so only two in example):
 
post-455771-0-20507500-1423151672_thumb.png
 
 
Hope you like it,
pascal.
  • Like 1
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...