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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T13:04:36+00:00 2026-06-14T13:04:36+00:00

thanks in advance to anyone who knows the answer to this as this problem

  • 0

thanks in advance to anyone who knows the answer to this as this problem makes me want to hurt kittens.

In Symfony2 I have a Doctrine entity set up like below.

namespace Product\ProductCoreBundle\Entity;

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Cache\ArrayCache;
use Doctrine\Common\Persistence\PersistentObject;
use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Table(name="item")
 * @ORM\Entity(repositoryClass="Product\ProductCoreBundle\Repositories\ProductRepository")
 */
class Product extends PersistentObject
{
    /**
     * 
     * @var ArrayCollection
     * @ORM\OneToMany(targetEntity="Product\ProductCoreBundle\Entity\ItemPrice", mappedBy="product", fetch="EAGER")
     */
    protected $prices;

    public function __construct() {
        $this->prices = new ArrayCollection();
    }
}

This is very very cut down to include only the offending item. $prices should be an array of all the prices associated to this item accross all of the locales we cover (GBP, EUR etc…) and the ItemPrice entity is set up like:

namespace Product\ProductCoreBundle\Entity;

use Doctrine\Common\Persistence\PersistentObject;
use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Table(name="itemprice")
 * @ORM\Entity(repositoryClass="Product\ProductCoreBundle\Repositories\ItemPriceRepository")
 */
class ItemPrice extends PersistentObject
{
    /**
     * The Product that this price is for.
     * @var Product
     * @ORM\ManyToOne(targetEntity="Product", inversedBy="prices")
     * @ORM\JoinColumn(name="item_code", referencedColumnName="item_code")
     */
    protected $product;
}

I then do a:

$pr = $this->getDoctrine()->getRepository('MPProductProductCoreBundle:Product');
$product = $pr->findByPublicId({some_id});

But I only get back the product and ONE price entry. when I look in the Symfony debug console and get the query that was executed and execute it against the database I get 2 prices back for 2 different locales, like I should do.

I’m now really stuck on fixing this one. Anyone got any clues about what I’m doing wrong?

  • 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-14T13:04:37+00:00Added an answer on June 14, 2026 at 1:04 pm

    As it turns out the fix for this was quite simple. We have a database where the item is stored separate from the item price as we support different prices in different countries. In the item price entity the item code was set as the ID of that entity. As such the entity was complaining that there was 2 rows in the database with the same “ID” and thus only returning one of them.

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

Sidebar

Related Questions

Thanks in advance to anyone who can think of a more efficient or a
Thanks in Advance for reading and answer this question. I got button in asp
Thanks in advance, I am trying to redirect anyone who types in example.com or
I want to ask anyone who knows how to create a bar graph in
Thank you in advance for anyone who helps with this. I know i've seen
Thanks in advance for your help. I have a need within an application to
thanks in advance for looking at this. Essentially, I'm calling didInsertElement() and binding an
Thanks in advance for your assistance. I have the following exported part: [Export (typeof(INewComponent))]
Thanks in advance for any help you can provide on this issue! I manage
Thanks in advance for your help experts. I want to be able to copy

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.