Jump to content

Manufacturer & Supplier : How to layout?


Recommended Posts

he there

i'm currently working on a music distribution webshop.
i use supplier.php to display "all labels" and manufacturers.php for "all artists"

i'm rooted to the spot that manufacturers.php & suppliers.php display the max. defined amount
of displayed products (=12)

is it possible to display all entries on one page ?

i've attached an image of the current situation.
i've already blocked the images.

regards
karl

36167_MKw0c1wm8ZeSDXX4cKvN_t

Link to comment
Share on other sites

The output of supplier-list.tpl and manufacturer-list.tpl is both generated in supplier.php.

In that file find the following portion of code:

        $data = call_user_func(array($className, 'get'.$className.'s'), true, intval($cookie->id_lang), true, $p, $n);
       $imgDir = $objectType == 'supplier' ? _PS_SUPP_IMG_DIR_ : _PS_MANU_IMG_DIR_;
       foreach ($data AS &$item)
               $item['image'] = (!file_exists($imgDir.'/'.$item['id_'.$objectType].'-medium.jpg')) ?
                       Language::getIsoById(intval($cookie->id_lang)).'-default' :        $item['id_'.$objectType];

       $smarty->assign(array(
               'pages_nb' => ceil($nbProducts / intval($n)),
               'nb'.$className.'s' => $nbProducts,
               'mediumSize' => Image::getSize('medium'),
               $objectType.'s' => $data
       ));
       $smarty->display(_PS_THEME_DIR_.$objectType.'-list.tpl');



Now swap all the $n variables for the specific number of manufacturers you want displayed eg 1000:

        $data = call_user_func(array($className, 'get'.$className.'s'), true, intval($cookie->id_lang), true, $p, '1000');
       $imgDir = $objectType == 'supplier' ? _PS_SUPP_IMG_DIR_ : _PS_MANU_IMG_DIR_;
       foreach ($data AS &$item)
               $item['image'] = (!file_exists($imgDir.'/'.$item['id_'.$objectType].'-medium.jpg')) ?
                       Language::getIsoById(intval($cookie->id_lang)).'-default' :        $item['id_'.$objectType];

       $smarty->assign(array(
               'pages_nb' => ceil($nbProducts / intval('1000')),
               'nb'.$className.'s' => $nbProducts,
               'mediumSize' => Image::getSize('medium'),
               $objectType.'s' => $data
       ));
       $smarty->display(_PS_THEME_DIR_.$objectType.'-list.tpl');



...and you're done.

Link to comment
Share on other sites

There still is a slight little problem:

The interval for displaying pagination page content is adjusted as described above. But the interval for creating the pagination links is apparently not affected. Resulting in non functional pagination links to show up on the page. Assistance needed!

For the time being you problem can be solved removing the pagination call from your theme's manufacturer-list.tpl and supplier-list.tpl.

That is this little snippet: {include file=$tpl_dir./pagination.tpl}

Link to comment
Share on other sites

  • 1 month later...
  • 1 year later...
  • 1 month later...

Better to override (1.4.8 - 1.4.9)

create a new file and copy paste the following:

 

<?php
class Manufacturer extends ManufacturerCore
{
public static function getManufacturers($getNbProducts = false, $id_lang = 0, $active = true, $p = false, $n = false, $all_group = false)
{
 if (!$id_lang)
  $id_lang = (int)Configuration::get('PS_LANG_DEFAULT');
 $sql = 'SELECT m.*, ml.`description`';
 $sql.= ' FROM `'._DB_PREFIX_.'manufacturer` m
 LEFT JOIN `'._DB_PREFIX_.'manufacturer_lang` ml ON (m.`id_manufacturer` = ml.`id_manufacturer` AND ml.`id_lang` = '.(int)($id_lang).')
 '.($active ? ' WHERE m.`active` = 1' : '');
 $sql.= ' ORDER BY m.`name` ASC'.($p ? ' LIMIT '.(((int)($p) - 1) * (int)(1000)).','.(int)(1000) : '');
 $manufacturers = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($sql);
 if ($manufacturers === false)
  return false;
 if ($getNbProducts)
 {
  $sqlGroups = '';
  if (!$all_group)
  {
   $groups = FrontController::getCurrentCustomerGroups();
   $sqlGroups = (count($groups) ? 'IN ('.implode(',', $groups).')' : '= 1');
  }
  foreach ($manufacturers as $key => $manufacturer)
  {
   $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('SELECT p.`id_product`
   FROM `'._DB_PREFIX_.'product` p
   LEFT JOIN `'._DB_PREFIX_.'manufacturer` as m ON (m.`id_manufacturer`= p.`id_manufacturer`)
   WHERE m.`id_manufacturer` = '.(int)($manufacturer['id_manufacturer']).
   ($active ? ' AND p.`active` = 1 ' : '').
   ($all_group ? '' : ' AND p.`id_product` IN (
 SELECT cp.`id_product`
 FROM `'._DB_PREFIX_.'category_group` cg
 LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_category` = cg.`id_category`)
 WHERE cg.`id_group` '.$sqlGroups.')'));
   $manufacturers[$key]['nb_products'] = sizeof($result);
  }
 }
 $rewrite_settings = (int)Configuration::get('PS_REWRITING_SETTINGS');
 for ($i = 0; $i < sizeof($manufacturers); $i++)
  if ($rewrite_settings)
   $manufacturers[$i]['link_rewrite'] = Tools::link_rewrite($manufacturers[$i]['name'], false);
  else
   $manufacturers[$i]['link_rewrite'] = 0;
 return $manufacturers;
}
}

 

Change the number 1000 to any number fitting your needs (the number of total objects that you want to be displayed in manufacturer-list.tpl)

 

Save as Manufacturer.php in your /override/classes/ folder

 

Done : )

  • Like 1
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...