INSTALLATION
------------

For the module to work properly you have to modify two files which contain functions responsible for searching data.

Grzegorz Kowalski
(grzegorz.kowalski@wit.edu.pl)


METHOD 1 - Prestashop 1.1

1. In prestashop folder find file "search.php".
2. Copy this code:

/* Attribute IDs */
elseif ($attribute_id = Tools::getValue('attribute_id'))
{
	$search = new Search();
	$nbProducts = intval($search->attribute_id(intval($cookie->id_lang), $attribute_id, true));
	include(dirname(__FILE__).'/pagination.php');
	$smarty->assign(array(
		'attribute_id' => $attribute_id,
		'products' => $search->attribute_id(intval($cookie->id_lang), $attribute_id, false, $p, $n),
		'nbProducts' => $nbProducts));
}

3. Paste it just before /* Tags */ comment
4. Now, go to folder "classes".
5. Find file "Search.php" (yes, its the same name but this is completely diffrent file)
6. Find "public function tag"
7. Copy following code:

	/**
	* @param integer $id_lang Language id for results
	* @param string $attribute_id Attribute ID to find
	* @param boolean $count Only to get number of results (optional)
	* @param string $pageNumber Current page (optional)
	* @param string $pageSize Results per page (optional)
	* @return array Attribute ID search results
	*/
	public function attribute_id($id_lang, $attribute_id, $count = false, $pageNumber = 0, $pageSize = 10)
	{
	 	global $link;

		if (!is_numeric($pageNumber) OR !is_numeric($pageSize) 
		OR !Validate::isBool($count) OR !Validate::isValidSearch($tag))
			die(Tools::displayError());
		
		if ($pageNumber < 0) $pageNumber = 0;
		if ($pageSize < 1) $pageSize = 10;

		/* Only if we need total results number */
		if ($count)
		{
			$result = Db::getInstance()->getRow('
			SELECT
			COUNT(DISTINCT p.`id_product`) AS nb
			FROM 
			`'._DB_PREFIX_.'product` AS p,
			`'._DB_PREFIX_.'product_attribute` AS ppa,
			`'._DB_PREFIX_.'product_attribute_combination` AS ppac
			WHERE
			ppac.`id_attribute` = '.$attribute_id.' AND
			ppa.`id_product_attribute` = ppac.`id_product_attribute` AND
			p.`id_product` = ppa.`id_product` AND
			p.`active` = 1');
			return isset($result['nb']) ? $result['nb'] : 0;
		}

		$result = Db::getInstance()->ExecuteS('
		SELECT
		p.*,
		pl.`description_short`,
		pl.`link_rewrite`,
		pl.`name`,
		tax.`rate`,
		i.`id_image`,
		il.`legend`
		FROM 
		`'._DB_PREFIX_.'product` AS p,
		`'._DB_PREFIX_.'product_attribute` AS ppa,
		`'._DB_PREFIX_.'product_attribute_combination` AS ppac,
		`'._DB_PREFIX_.'product_lang` AS pl,
		`'._DB_PREFIX_.'image` AS i,
		`'._DB_PREFIX_.'image_lang` AS il,
		`'._DB_PREFIX_.'tax` as tax
		WHERE
		ppac.`id_attribute` = '.$attribute_id.' AND
		ppa.`id_product_attribute` = ppac.`id_product_attribute` AND
		p.`id_product` = ppa.`id_product` AND
		p.`id_product` = pl.`id_product` AND
		pl.`id_lang` = '.intval($id_lang).' AND		
		i.`id_product` = p.`id_product` AND
		i.`cover` = 1 AND
		p.`id_tax` = tax.`id_tax` AND
		p.`active` = 1
		GROUP BY
		p.`id_product`');

		if (!$result) return false;

		return Product::getProductsProperties($id_lang, $result);
	}

8. And paste it just before comments above public function tag
9. That's it. Now istall module blocksearchbyattribute just like you normally do.


METHOD 2 - for Prestashop v 1.18 BETA (from www.prestashop.pl)

1. Just copy all files as they are into their respective folders.