Jump to content

Recommended Posts

How should I set the Hooks in blockviewed.php to appear listed in my Cshometab. I know that after I set the TabClass.php in cshometab module...

 

What I have done ... :

 

BlockViewed.php:

....
public function hookdisplayHomeTabContent($params)
{

}


public function hookdisplayHomeTab($params)
{

}....

TabClass.php

.....
elseif(strpos($this->product_type, "products_viewed") !== false)
		{
			unset($this->product_list);
		
			
			/*$this->product_list = BlockViewed::getProductsViewed((int)($cookie->id_lang), 0, $nb);
			$link=new Link();
			$this->view_more= '';*/
			
			$productsViewed = (isset($cookie->viewed) && !empty($cookie->viewed)) ? array_slice(array_reverse(explode(',', $cookie->viewed)), 0, Configuration::get('PRODUCTS_VIEWED_NBR')) : array();
			
			if (count($productsViewed))
			{
				$defaultCover = Language::getIsoById($cookie->id_lang).'-default';

				$productIds = implode(',', array_map('intval', $productsViewed));
				$count = count($productsViewed);
				for($i = 0; $i < $count; $i++){
					$productsImages[] = Db::getInstance()->getRow('
					SELECT MAX(image_shop.id_image) id_image, p.*, il.legend, product_shop.active, pl.name, pl.description_short, pl.link_rewrite, cl.link_rewrite AS category_rewrite
					FROM '._DB_PREFIX_.'product p
					'.Shop::addSqlAssociation('product', 'p').'
					LEFT JOIN '._DB_PREFIX_.'product_lang pl ON (pl.id_product = p.id_product'.Shop::addSqlRestrictionOnLang('pl').')
					LEFT JOIN '._DB_PREFIX_.'image i ON (i.id_product = p.id_product)'.'
					LEFT JOIN '._DB_PREFIX_.'product_attribute pa ON (pa.id_product = p.id_product)'.
					Shop::addSqlAssociation('image', 'i', false, 'image_shop.cover=1').'
					LEFT JOIN '._DB_PREFIX_.'image_lang il ON (il.id_image = image_shop.id_image AND il.id_lang = '.(int)($cookie->id_lang).')
					LEFT JOIN '._DB_PREFIX_.'category_lang cl ON (cl.id_category = product_shop.id_category_default'.Shop::addSqlRestrictionOnLang('cl').')
					WHERE p.id_product = '.$productsViewed[$i].'
					AND pl.id_lang = '.(int)($cookie->id_lang).'
					AND cl.id_lang = '.(int)($cookie->id_lang).'
					GROUP BY product_shop.id_product'
					);
				}
				$productsImagesArray = array();
				foreach ($productsImages as $pi){
					$productsImagesArray[$pi['id_product']] = $pi;
					$productsImagesArray[$pi['id_product']]['link'] = _PS_BASE_URL_.__PS_BASE_URI__.$pi['category_rewrite'].'/'.$pi['link_rewrite'].'-'.$pi['id_product'].'.html';
					$productsImagesArray[$pi['id_product']]['quantity_all_versions'] = $pi['quantity'];
					$productsImagesArray[$pi['id_product']]['allow_oosp'] = Product::isAvailableWhenOutOfStock($pi['out_of_stock']);
					$productsImagesArray[$pi['id_product']]['reduction'] = Product::getPriceStatic((int)$pi['id_product'],(bool)$usetax,(int)$PI['id_product_attribute'],
					6,null,true,true,1,true,null,null,null,$specific_prices);
					$productsImagesArray[$pi['id_product']]['specific_prices'] = $specific_prices;
					$ipa_default = Product::getDefaultAttribute($pi['id_product']);
					$productsImagesArray[$pi['id_product']]['id_product_attribute'] = $ipa_default;
					//echo "<br><br><br>".$ipa_default."<br><br><br>";
					$productsImagesArray[$pi['id_product']]['price_without_reduction'] = Product::getPriceStatic((int)$pi['id_product'],false,
					((isset($ipa_default) && !empty($ipa_default)) ? (int)$ipa_default : null),2,null,false,false);
				}
				$this->productsViewed = count($productsViewed);
				//var_dump($productsImagesArray);
				foreach($productsImagesArray as $item)
					$this->product_list[] = $item;
				//var_dump($this->product_list);
				
			}
		}	
....

This almost ready , just do not know how to set the hooks , someone give me a light?

Link to comment
Share on other sites

TabClass.php ? im probably missed something... but i have not idea why you want to deal with this file? From where you've got it? 

 

let's clarify,

you just simply want to move block viewed module to homepage tabs feature? nothing more, right?

 

what theme? default one?

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