Jump to content

Modificar crossseling


pedropalamos

Recommended Posts

Hola, necesitaria modificar el carrusel de productos que salen cuando un cliente compra un articulo y en el bloque de información sobre el producto (el nuevo splash de las plantillas 1.6) salen lo de "Otros clientes tambien compraron". 

 

Básicamente necesitaria que no salieran los productos que són de una categoria determinada. 

 

 

Muchas gracias de antemano.

Link to comment
Share on other sites

edita el crosseling.php que esta en modulos, tendras la funcion 

public function hookProductFooter($params)
	{
		$cache_id = 'crossselling|productfooter|'.(int)$params['product']->id;

		if (!$this->isCached('crossselling.tpl', $this->getCacheId($cache_id)))
		{
			$orders = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(
			'SELECT o.id_order
			FROM '._DB_PREFIX_.'orders o
			LEFT JOIN '._DB_PREFIX_.'order_detail od ON (od.id_order = o.id_order)
			WHERE o.valid = 1 AND od.product_id = '.(int)$params['product']->id
			);

			if (count($orders))
			{
				$list = '';
				foreach ($orders as $order)
					$list .= (int)$order['id_order'].',';
				$list = rtrim($list, ',');

				if (Group::isFeatureActive())
				{
					$sql_groups_join = '
					LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_category` = product_shop.id_category_default
						AND cp.id_product = product_shop.id_product)
					LEFT JOIN `'._DB_PREFIX_.'category_group` cg ON (cp.`id_category` = cg.`id_category`)';
					$groups = FrontController::getCurrentCustomerGroups();
					$sql_groups_where = 'AND cg.`id_group` '.(count($groups) ? 'IN ('.implode(',', $groups).')' : '='.(int)Group::getCurrent()->id);
				}

				$order_products = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
					SELECT DISTINCT od.product_id, pl.name, pl.link_rewrite, p.reference, i.id_image, product_shop.show_price,
						cl.link_rewrite category, p.ean13, stock.out_of_stock, IFNULL(stock.quantity, 0) as quantity
					FROM '._DB_PREFIX_.'order_detail od
					LEFT JOIN '._DB_PREFIX_.'product p ON (p.id_product = od.product_id)
					'.Shop::addSqlAssociation('product', 'p').
					(Combination::isFeatureActive() ? 'LEFT JOIN `'._DB_PREFIX_.'product_attribute` pa
					ON (p.`id_product` = pa.`id_product`)
					'.Shop::addSqlAssociation('product_attribute', 'pa', false, 'product_attribute_shop.`default_on` = 1').'
					'.Product::sqlStock('p', 'product_attribute_shop', false, $this->context->shop) :  Product::sqlStock('p', 'product', false,
						$this->context->shop)).'
					LEFT JOIN '._DB_PREFIX_.'product_lang pl ON (pl.id_product = od.product_id'.Shop::addSqlRestrictionOnLang('pl').')
					LEFT JOIN '._DB_PREFIX_.'category_lang cl ON (cl.id_category = product_shop.id_category_default'
						.Shop::addSqlRestrictionOnLang('cl').')
					LEFT JOIN '._DB_PREFIX_.'image i ON (i.id_product = od.product_id)
					'.(Group::isFeatureActive() ? $sql_groups_join : '').'
					WHERE od.id_order IN ('.$list.')
					AND pl.id_lang = '.(int)$this->context->language->id.'
					AND cl.id_lang = '.(int)$this->context->language->id.'
					AND od.product_id != '.(int)$params['product']->id.'
					AND i.cover = 1
					AND product_shop.active = 1
					'.(Group::isFeatureActive() ? $sql_groups_where : '').'
					ORDER BY RAND()
					LIMIT '.(int)Configuration::get('CROSSSELLING_NBR')
				);

				$tax_calc = Product::getTaxCalculationMethod();
				$final_products_list = array();

				foreach ($order_products as &$order_product)
				{
					$order_product['id_product'] = (int)$order_product['product_id'];
					$order_product['image'] = $this->context->link->getImageLink($order_product['link_rewrite'],
						(int)$order_product['product_id'].'-'.(int)$order_product['id_image'], ImageType::getFormatedName('home'));
					$order_product['link'] = $this->context->link->getProductLink((int)$order_product['product_id'], $order_product['link_rewrite'],
						$order_product['category'], $order_product['ean13']);
					if (Configuration::get('CROSSSELLING_DISPLAY_PRICE') && ($tax_calc == 0 || $tax_calc == 2))
						$order_product['displayed_price'] = Product::getPriceStatic((int)$order_product['product_id'], true, null);
					elseif (Configuration::get('CROSSSELLING_DISPLAY_PRICE') && $tax_calc == 1)
						$order_product['displayed_price'] = Product::getPriceStatic((int)$order_product['product_id'], false, null);
					$order_product['allow_oosp'] = Product::isAvailableWhenOutOfStock((int)$order_product['out_of_stock']);

					if (!isset($final_products_list[$order_product['product_id'].'-'.$order_product['id_image']]))
						$final_products_list[$order_product['product_id'].'-'.$order_product['id_image']] = $order_product;
				}

				$this->smarty->assign(
					array(
						'order' => false,
						'orderProducts' => $final_products_list,
						'middlePosition_crossselling' => round(count($final_products_list) / 2, 0),
						'crossDisplayPrice' => Configuration::get('CROSSSELLING_DISPLAY_PRICE')
					)
				);
			}
		}

		return $this->display(__FILE__, 'crossselling.tpl', $this->getCacheId($cache_id));
	}

modifica la consulta por esto

 

$order_products = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT DISTINCT od.product_id, pl.name, pl.link_rewrite, p.reference, i.id_image, product_shop.show_price
cl.link_rewrite category, p.ean13, stock.out_of_stock, IFNULL(stock.quantity, 0) as quantity
FROM '._DB_PREFIX_.'order_detail od
LEFT JOIN '._DB_PREFIX_.'product p ON (p.id_product = od.product_id)
'.Shop::addSqlAssociation('product', 'p').
(Combination::isFeatureActive() ? 'LEFT JOIN `'._DB_PREFIX_.'product_attribute` pa
ON (p.`id_product` = pa.`id_product`)
'.Shop::addSqlAssociation('product_attribute', 'pa', false, 'product_attribute_shop.`default_on` = 1').'
'.Product::sqlStock('p', 'product_attribute_shop', false, $this->context->shop) :  Product::sqlStock('p', 'product', false,
$this->context->shop)).'
LEFT JOIN '._DB_PREFIX_.'product_lang pl ON (pl.id_product = od.product_id'.Shop::addSqlRestrictionOnLang('pl').')
LEFT JOIN '._DB_PREFIX_.'category_lang cl ON (cl.id_category = product_shop.id_category_default'
.Shop::addSqlRestrictionOnLang('cl').')
LEFT JOIN '._DB_PREFIX_.'image i ON (i.id_product = od.product_id)
'.(Group::isFeatureActive() ? $sql_groups_join : '').'
WHERE od.id_order IN ('.$list.')
AND pl.id_lang = '.(int)$this->context->language->id.'
AND cl.id_lang = '.(int)$this->context->language->id.'
AND od.product_id != '.(int)$params['product']->id.'
AND i.cover = 1
AND product_shop.id_category_default NOT IN (1)
AND product_shop.active = 1
'.(Group::isFeatureActive() ? $sql_groups_where : '').'
ORDER BY RAND()
LIMIT '.(int)Configuration::get('CROSSSELLING_NBR')
);

Fijate la linea que agregue es 

 

AND product_shop.id_category_default NOT IN (1)

 

1 es el id de la categoria que no quieres mostrar

Link to comment
Share on other sites

Gracias Shaker, he hecho las modificaciones en el crosselling.php pero no acaba de funcionar. Este es el código añadido:

 

$order_products = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT DISTINCT od.product_id, pl.name, pl.link_rewrite, p.reference, i.id_image, product_shop.show_price,
cl.link_rewrite category, p.ean13, stock.out_of_stock, IFNULL(stock.quantity, 0) as quantity
FROM '._DB_PREFIX_.'order_detail od
LEFT JOIN '._DB_PREFIX_.'product p ON (p.id_product = od.product_id)
'.Shop::addSqlAssociation('product', 'p').
(Combination::isFeatureActive() ? 'LEFT JOIN `'._DB_PREFIX_.'product_attribute` pa
ON (p.`id_product` = pa.`id_product`)
'.Shop::addSqlAssociation('product_attribute', 'pa', false, 'product_attribute_shop.`default_on` = 1').'
'.Product::sqlStock('p', 'product_attribute_shop', false, $this->context->shop) :  Product::sqlStock('p', 'product', false,
$this->context->shop)).'
LEFT JOIN '._DB_PREFIX_.'product_lang pl ON (pl.id_product = od.product_id'.Shop::addSqlRestrictionOnLang('pl').')
LEFT JOIN '._DB_PREFIX_.'category_lang cl ON (cl.id_category = product_shop.id_category_default'
.Shop::addSqlRestrictionOnLang('cl').')
LEFT JOIN '._DB_PREFIX_.'image i ON (i.id_product = od.product_id)
'.(Group::isFeatureActive() ? $sql_groups_join : '').'
WHERE od.id_order IN ('.$list.')
AND pl.id_lang = '.(int)$this->context->language->id.'
AND cl.id_lang = '.(int)$this->context->language->id.'
AND od.product_id NOT IN ('.$list_product_ids.')
AND i.cover = 1
AND product_shop.id_category_default NOT IN (11)
AND product_shop.active = 1
'.(Group::isFeatureActive() ? $sql_groups_where : '').'
ORDER BY RAND()
LIMIT '.(int)Configuration::get('CROSSSELLING_NBR').'
'
);
 
 
 
 
Como puedes ver la categoría en cuestión es la 11 y siguen saliendo los productos en el listado. 
 
Un apunte, no se trata solo del listado de productos que salen debajo del producto, si no que también son los que salen cuando se añade un producto en la cesta.

 

Link to comment
Share on other sites

  • nadie locked this topic
Guest
This topic is now closed to further replies.
×
×
  • Create New...