Jump to content

[QUESTION]Manufacturer listing modification


Recommended Posts

  • 3 weeks later...

I'm using 1.5.6.0.

I have deleted pagination.tpl from my manufacturer-list.tpl, but that's not working.

 

I have 14 manufacturers and in backoffice i have set to only show 12 products.

As you can see, in http://shop.jenci.ro/manufacturers it shows 12 of them, but you can see the other 2 on http://shop.jenci.ro/manufacturers?p=2 (second page of manufacturers), so removing pagination.tpl does not solve my problem.

 

Any ideeas?

Edited by monova (see edit history)
Link to comment
Share on other sites

  • 4 months later...

Did you ever sort this out? I found that the manufacturer list in this version uses the default pagination entry for products, so if you set the default pagination in the preferences section to, say 1000, it will remove pagination from the manufacturers page (if you have fewer than 1000 manufacturers!), but it also sets the products to 1000 per page. Not ideal.

 

I have solved this, but only after editing the database:

 

1. I added a line to the PS_configuration table, copying the PS_PRODUCTS_PER_PAGE line, and naming it PS_MANUFACTURERS_PER_PAGE, giving it a value of 1000.

 

2. I edited the ManufacturerController.php file (around line 118), changing the reference to PS_PRODUCTS_PER_PAGE to PS_MANUFACTURERS_PER_PAGE.

 

3. Removed the line {include file="$tpl_dir./pagination.tpl"} (around line 67) in manufacturer-list.tpl.

 

I can now see all my manufacturers, and it leave all other pages unaffected.

Just to say, I have pretty much no knowledge of how to edit a database, so backed the table up before I did anything, and had extremely sweaty hands for a few minutes while checking my mods!!

 

I hope this helps anyone else who has the same problem.

Link to comment
Share on other sites

Geia sas,

 

garyjj127's proposition woudl work maybe and could save the day, yet I'm afraid it won't be the correct approach to alter the core database.

In fact, your simple question is quite a challange for the programmers as while there would be at least three or four decent ways to do that, it's the first time for me to see such a request and probably I'm not alone in this.

 

If it's not that urgent, I'd like to see what other programmers have to say in this so you'll also benefit from the best solution, otherwise I can share my ideas.

Link to comment
Share on other sites

First, just like garyjj127 (post #8) I faced the question how to increase the number of returned records. I too used a hack in the function assignAll() in manufacturerController.php. My hack was inserting an extra line that overrules the PS_PRODUCTS_PER_PAGE:

$this->n = abs((int)(Tools::getValue('n', Configuration::get('PS_PRODUCTS_PER_PAGE')))); /* after this line ... */
$this->n = 999; /* ... an extra line inserted */

The rest of the mod is in the attached manufacturer-list.tpl file. Note that at the beginning I have a loop that filters out all manufacturers with zero products and puts the remaining manufacturers in a new array: $manufacturersx.

 

 

BTW I am using PS 1.5.6.1

 

 

manufacturer-list.zip

  • Like 1
Link to comment
Share on other sites

Because while there are more than one possible solutions without altering the core database, we need to favor them as if we ever want to upgrade one day, the auto upgrade itself may fail and/or the changes we did on the database may get lost so we'll stay with barehand, barefoot. For practical reasons like that, the theory says not to touch the core database structure unless you 100% have to.

Link to comment
Share on other sites

When people (third-party developers) need to alter the existing database structure, they usually intend to do what we call" database denormalization" and create a mySQL view, so that you will have two separate tables (one being the original and the new one containing your own fields) and you can use them as a single table.

 

If you are ever interested to learn more or for anybody who will need such a solution in the future, you can check mySQL's "CREATE VIEW" syntax.

Link to comment
Share on other sites

I see there is a discussion about the proposal of Garyjj127 in post #8 to add a configuration variable. My view is the following:

 - the configuration table was made for that purpose. If you check the latest entries in the configuration table you will see that they are from the third party modules that you use.

 - As far as I understood, what Garyjj127 proposed was just adding an entry to the configuration table. Not changing its structure. So I don't see any problem with that in connection to updates.

 - however, it is good use to have a author specific prefix. So rather than  PS_MANUFACTURERS_PER_PAGE you should make an entry like GARYJJ_MANUFACTURERS_PER_PAGE. That way you avoid problems if Prestashop might add new functionality in the future.

 - Adding an entry directly to the database is a bit rude. You could let Prestashop do that for you. If I am correct (I haven't tested the code) it would be 

Configuration::updateValue('GARYJJ_MANUFACTURERS_PER_PAGE', 1000);
  • Like 1
Link to comment
Share on other sites

@musicmaster: For this issue spesific, you are right and your solution will work. That was why originally I wanted to see more than one ideas. There's also another point to keep in mind: The performance. When you create a separate table and a view (which is a simple mysql "JOIN" query in turn, but the difference is that it's cached) the benchmarks would be quite different.

Anyway, after this point, maybe it's hypothetical and needlessly complicated for such in issue and thank you for sharing your solution.

Edited by prestashopninja (see edit history)
Link to comment
Share on other sites

Yes I agree it's much easier to use musicmasters solution for this problem, as it's far easier to implement, and there's no need to mess with the database. I guess there are arguments both ways for adding lines to the database, as there are obviously other issues that can be solved this way. I just wanted clarification on whether database mods would impact future updates, and musicmasters last post seems like a very good idea!

Link to comment
Share on other sites

×
×
  • Create New...