Jump to content

[Dica] Produtos aleatório no módulo "homefeatured"


Recommended Posts

Entrei no post abaixo ( em inglês );

http://www.prestashop.com/forums/topic/164821-random-product-display-on-featured-page/page-4?do=findComment&comment=1594984

Para resolver um "problema" na minha instalação do prestashop (1.5.6.2), e lendo as dicas dos moderadores e usuários, cheguei na seguinte solução;

 


public function hookDisplayHome($params) {
		
			$category = new Category(Context::getContext()->shop->getCategory(), (int)Context::getContext()->language->id);
			$nb = (int)Configuration::get('HOME_FEATURED_NBR');
			$products = $category->getProducts((int)Context::getContext()->language->id, 1, ($nb ? $nb : 8), "position");
            
			if ($products) {
		        shuffle($products);
		        array_splice($products, ($nb ? $nb : 10));
		    }
			
			$this->smarty->assign(array(
				'products' => $products,
				'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'),
				'homeSize' => Image::getSize(ImageType::getFormatedName('home')),
			));
		return $this->display(__FILE__, 'homefeatured.tpl');
	}

Estou aberto a sugestões e melhorias da solução.

Edited by Cassiano Aquino (see edit history)
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...