Jump to content

Edit History

w3bsolutions

w3bsolutions

Puedes cambiar el orden en el que se muestran en el módulo por defecto a que sea aleatorio bastante fácil:

en /modules/ps_imageslider/ps_imageslider.php cambia:

$slides = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
    SELECT hs.`id_homeslider_slides` as id_slide, hss.`position`, hss.`active`, hssl.`title`,
    hssl.`url`, hssl.`legend`, hssl.`description`, hssl.`image`
    FROM '._DB_PREFIX_.'homeslider hs
    LEFT JOIN '._DB_PREFIX_.'homeslider_slides hss ON (hs.id_homeslider_slides = hss.id_homeslider_slides)
    LEFT JOIN '._DB_PREFIX_.'homeslider_slides_lang hssl ON (hss.id_homeslider_slides = hssl.id_homeslider_slides)
    WHERE id_shop = '.(int)$id_shop.'
    AND hssl.id_lang = '.(int)$id_lang.
    ($active ? ' AND hss.`active` = 1' : ' ').'
    ORDER BY hss.position'
);

por (sólo cambia la última línea):

$slides = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
    SELECT hs.`id_homeslider_slides` as id_slide, hss.`position`, hss.`active`, hssl.`title`,
    hssl.`url`, hssl.`legend`, hssl.`description`, hssl.`image`
    FROM '._DB_PREFIX_.'homeslider hs
    LEFT JOIN '._DB_PREFIX_.'homeslider_slides hss ON (hs.id_homeslider_slides = hss.id_homeslider_slides)
    LEFT JOIN '._DB_PREFIX_.'homeslider_slides_lang hssl ON (hss.id_homeslider_slides = hssl.id_homeslider_slides)
    WHERE id_shop = '.(int)$id_shop.'
    AND hssl.id_lang = '.(int)$id_lang.
    ($active ? ' AND hss.`active` = 1' : ' ').'
    ORDER BY rand()'
);

y luego cambia:

public function renderWidget($hookName = null, array $configuration = [])
{
  	if (!$this->isCached($this->templateFile, $this->getCacheId())) {
  		$this->smarty->assign($this->getWidgetVariables($hookName, $configuration));
	}

	return $this->fetch($this->templateFile, $this->getCacheId());
}

por:

public function renderWidget($hookName = null, array $configuration = [])
{
  	$this->smarty->assign($this->getWidgetVariables($hookName, $configuration));
	return $this->fetch($this->templateFile, $this->getCacheId());
}

 

et voilà!

 

P.S. Lo mejor es hacer esto con un override, para no perder los cambios cuando actualices el módulo. 

w3bsolutions

w3bsolutions

Puedes cambiar el orden en el que se muestran en el módulo por defecto a que sea aleatorio bastante fácil:

en /modules/ps_imageslider/ps_imageslider.php cambia:

$slides = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
    SELECT hs.`id_homeslider_slides` as id_slide, hss.`position`, hss.`active`, hssl.`title`,
    hssl.`url`, hssl.`legend`, hssl.`description`, hssl.`image`
    FROM '._DB_PREFIX_.'homeslider hs
    LEFT JOIN '._DB_PREFIX_.'homeslider_slides hss ON (hs.id_homeslider_slides = hss.id_homeslider_slides)
    LEFT JOIN '._DB_PREFIX_.'homeslider_slides_lang hssl ON (hss.id_homeslider_slides = hssl.id_homeslider_slides)
    WHERE id_shop = '.(int)$id_shop.'
    AND hssl.id_lang = '.(int)$id_lang.
    ($active ? ' AND hss.`active` = 1' : ' ').'
    ORDER BY hss.position'
);

por (sólo cambia la última línea):

$slides = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
    SELECT hs.`id_homeslider_slides` as id_slide, hss.`position`, hss.`active`, hssl.`title`,
    hssl.`url`, hssl.`legend`, hssl.`description`, hssl.`image`
    FROM '._DB_PREFIX_.'homeslider hs
    LEFT JOIN '._DB_PREFIX_.'homeslider_slides hss ON (hs.id_homeslider_slides = hss.id_homeslider_slides)
    LEFT JOIN '._DB_PREFIX_.'homeslider_slides_lang hssl ON (hss.id_homeslider_slides = hssl.id_homeslider_slides)
    WHERE id_shop = '.(int)$id_shop.'
    AND hssl.id_lang = '.(int)$id_lang.
    ($active ? ' AND hss.`active` = 1' : ' ').'
    ORDER BY rand()'
);

y luego cambia:

public function renderWidget($hookName = null, array $configuration = [])
{
  	if (!$this->isCached($this->templateFile, $this->getCacheId())) {
  		$this->smarty->assign($this->getWidgetVariables($hookName, $configuration));
	}

	return $this->fetch($this->templateFile, $this->getCacheId());
}

por:

public function renderWidget($hookName = null, array $configuration = [])
{
  	$this->smarty->assign($this->getWidgetVariables($hookName, $configuration));
	return $this->fetch($this->templateFile, $this->getCacheId());
}

 

et voilà!

×
×
  • Create New...