Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6237479
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T11:02:12+00:00 2026-05-24T11:02:12+00:00

I’ve got a bestsellers module which I’ve written and it works great, however I

  • 0

I’ve got a bestsellers module which I’ve written and it works great, however I want to be able to change the collection size it returns via the XML, rather than the php/phtml.

Something like this:

    <block type="catalog/product_list" name="bestsellers" limit="3" 
template="custom/bestsellers.phtml" />

or something like:

    <block type="catalog/product_list" name="bestsellers" 
template="custom/bestsellers.phtml">
         <action method="setLimit">3</action>
    </block>

Is this possible?

I’m currently changing the limit via the phtml with:

->setPageSize(3)
->setCurPage(1);

But that is hard coded and nasty, I need to be able to use my phtml file as template for many cases of the bestsellers module being called from anywhere with the XML + limit in the XML.

Thanks in advance if anyone can shed light on this!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T11:02:13+00:00Added an answer on May 24, 2026 at 11:02 am

    The block Mage_Catalog_Block_Product_List inherits from the Varien_Object class which contains the methods getData() and setData(), as well as the magic methods get*() and set*(). These methods allow us to store (you guessed it) keyed-data within an object.

    The <action /> tags in the XML allows us to perform method calls on the block instances. You’re nearly there with your second example, but the syntax is:

    <block type="catalog/product_list" name="bestsellers">
        <action method="setLimit"><value>3</value></action>
    </block>
    

    Which is equivalent to:

    <block type="catalog/product_list" name="bestsellers">
        <action method="setData"><key>limit</key><value>3</value></action>
    </block>
    

    Which is roughly equivalent to:

    $block = new Mage_Catalog_Block_Product_List();
    $block->setLimit(3);
    

    With the data set in the object we can now access through the getData() or get*() methods by calling $this->getLimit() or $this->getData('limit') making our block code:

    ->setPageSize($this->getLimit())
    ->setCurPage(1);
    

    You should probably perform a check for the existence of the limit data first and provide a default value if none is provided in the XML.

    Note: The name of the children in the <action /> tag don’t matter. It’s the order of the arguments that’s important. We could just as well have called <action method="setLimit"><foo>3</foo></action> and it still would have worked.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to count how many characters a certain string has in PHP, but
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I've got a string that has curly quotes in it. I'd like to replace
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.