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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T20:43:35+00:00 2026-06-03T20:43:35+00:00

I’ve been struggling with some findBy using an entity and I really can’t understand

  • 0

I’ve been struggling with some findBy using an entity and I really can’t understand what’s wrong.

I’m using these two classes:

GPos_Model_Product :

/**
* @Entity
* @Table(name="Product")
*/
class GPos_Model_Product extends GPos_Doctrine_ActiveEntity {
    /**
     * @Id @Column(type="integer")
     * @GeneratedValue
     */
    protected $id;

    /**
     * @ManyToOne(targetEntity="GPos_Model_Store")
     * @JoinColumn(name="store_id", referencedColumnName="id")
     **/
    protected $store;
}

GPos_Model_Store:

/**
 * @Entity
 * @Table(name="Store")
 */
class GPos_Model_Store extends GPos_Doctrine_ActiveEntity {
    /**
     * @Id @Column(type="integer")
     * @GeneratedValue
     */
    protected $id;

    /** @Column(name="status", type="string", columnDefinition="enum('active', 'deleted')")  */
    protected $status = 'active';
}

Note: I’ve removed useless fields in both class to make it more readable

So here’s the problem:
In one of my controller I’m trying to retrieve all products that are linked to a certain store:

public function indexAction() {
    $this->_helper->getHelper('layout')->disableLayout();
    $authNamespace = new Zend_Session_Namespace('Zend_Auth');

    //get store's products list.
    $store = GPos_Model_Store::find($authNamespace->store);
    var_dump($store); //prints store successfully.
    //next line throws an unusable exception talking about layout.phtml not found...
    $products = GPos_Model_Product::findByStore($store->getId());
    //give it to the view for the products list rendering.
    var_dump($products);
    $this->view->products = $products;
}

Weird enough, when I use $products = GPos_Model_Product::findByStore($store); instead, I get no exception but simply an empty array as a result.
I used the exact same way (with getId()) in another controller about two other entities that have the same relation and that worked fine.

I checked my DB and the store I’m using as a parameter is indeed bound to a few products which means an empty array as a result isn’t correct either. I should retrieve an array of like 8 products…

Here’s the code of my other controller that is working fine (narrowed the code again):

$user = GPos_Model_User::findOneByLogin($form->getValue('login'));
$contact = GPos_Model_Contact::findByUser($user->getId());
//these lines work perfectly and I'm receiving an array of `GPos_Model_Contact` entities... 

These two pairs of entities are declared in the exact same way so I really don’t get it…

Thanks for your help!

  • 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-06-03T20:43:36+00:00Added an answer on June 3, 2026 at 8:43 pm

    YEAH!

    I found my mistake… It actually had nothing to do with my relations.
    My mistake was that I use gedmo and forgot to set a default locale, meaning it just couldn’t retrieve any products because it didn’t know where to look. Gedmo was throwing an exception but it was overridden by the layout not found exception (which is kind of a zend bug because there was no problem with my layout).

    Thanks to XDebug and a few hours of patience I was finally able to find the exact exception message and fix it in a few minutes.

    Thanks for anyone who paid attention anyway, it was my fault not providing enough code (with the gedmo stuff) because I thought this was actually well set…

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

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an ’ 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.