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 7046025
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:36:05+00:00 2026-05-28T02:36:05+00:00

I am defining a new block to clean up my view like so: class

  • 0

I am defining a new block to clean up my view like so:

class Jamie_Utilities_Block_Myblock extends Mage_Core_Block_Template
{
    public function getProducts()
    {
        $products = array(
            new Product('Product Name', "image source"),
            new Product('Product Name', "image source"),
        );
        return $products;
    }
}

I would like to create a little Product class in the same file to hold a couple fields. Myblock.php now looks like:

class Jamie_Utilities_Block_Myblock extends Mage_Core_Block_Template
{...}

class Product
{
    public $name;
    public $image;

    public function __construct($name, $image)
    {
        $this->name  = $name;
        $this->image = $image;
    }
}

This works, but is it a good thing to do? Should I be declaring all my classes as models in the module’s config.xml or should I just use a better class name to avoid conflicts e.g. Jamie_Utilities_Block_Product?

  • 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-28T02:36:06+00:00Added an answer on May 28, 2026 at 2:36 am

    The <models> node in your config is a class prefix, not a class name.

    An example config of <config><global><models><your_module><class>Yer_Module_Model</class></...> is what’s found when this code is parsed: Mage::getModel('your_module/rest_of_class_name');. The first part is converted to yer_module_model, and the rest is tacked on with a leading underscore, i.e. yer_module_model_rest_of_class_name. According to the autoloader, the system will look for that definition in Yer/Module/Model/Rest/Of/Classname.php.

    The short story is this: define your class prefix and you can create as many classes as you want.

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

Sidebar

Related Questions

When defining a new class within a project what is the correct/best practice for
Is there a way in C# sytax for defining a new line? (Like in
In Powershell I am defining a new PSDrive called test . But when I
I'm thinking about defining Restful urls for a new project (developed with Ruby On
I'm new to OOP. Originally I was defining variables and assigning values to them
I'm re-defining a method in an object in ruby and I need the new
When defining a string in a class using Code First, the default for the
I have a class that extends the HtmlHelper in MVC and allows me to
when defining new data types in C, one can do typedef double BYTE; so
After defining a new extension project to the Controller I have two problems: During

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.