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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T01:13:04+00:00 2026-06-11T01:13:04+00:00

I have Three entities: FeatureValue.php <?php namespace Webmuch\ProductBundle\Entity; use Doctrine\ORM\Mapping as ORM; /** *

  • 0

I have Three entities:

FeatureValue.php

<?php

namespace Webmuch\ProductBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity
 */
class FeatureValue
{
/**
 * @ORM\Id
 * @ORM\Column(type="integer")
 * @ORM\GeneratedValue(strategy="AUTO")
 */
protected $id;

/**
 * @ORM\Column(type="string", length="100")
 */
protected $name;

/** 
 * @ORM\OneToMany(targetEntity="FeatureType", mappedBy="name")
 */
private $featuretype;



public function __construct()
{
    $this->featuretype = new \Doctrine\Common\Collections\ArrayCollection();
}

FeatureType.php

<?php

namespace Webmuch\ProductBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Webmuch\ProductBundle\Entity\FeatureValue;

/**
 * @ORM\Entity
 */
class FeatureType
{
/**
 * @ORM\Id
 * @ORM\Column(type="integer")
 * @ORM\GeneratedValue(strategy="AUTO")
 */
protected $id;

/**
 * @ORM\Column(type="string", length=255, nullable=true)
 */   
protected $title;

/** 
 * @ORM\ManyToOne(targetEntity="FeatureValue", inversedBy="featuretype",cascade={"persist"})
 * @ORM\JoinColumn(name="feature_value_id", referencedColumnName="id")
 */    
protected $name;

 public function __construct() 
{
    $this->name = new \Doctrine\Common\Collections\ArrayCollection();
}

Product.php

<?php
namespace Webmuch\ProductBundle\Entity;

use Gedmo\Mapping\Annotation as Gedmo;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection as ArrayCollection;

/**
 * @ORM\Entity
 * @ORM\Table()
 * @ORM\HasLifecycleCallbacks
 */
class Product 
{
/**
 * @ORM\Id
 * @ORM\Column(type="integer")
 * @ORM\GeneratedValue(strategy="AUTO")
 */
protected $id;

/**
 * @ORM\ManyToMany(targetEntity="Store")
 */
protected $store;

/**
 * @ORM\ManyToMany(targetEntity="Webmuch\CategoryBundle\Entity\Category")
 */
protected $category;

/**
 * @Gedmo\Sluggable
 * @ORM\Column(type="string", length=255)
 */
protected $title;

/**
 * @Gedmo\Slug(updatable=false, unique=true)
 * @ORM\Column(type="string", length=255)
 */
protected $slug;

/**
 * @ORM\Column(type="integer")
 */
protected $quantity;

/**
 * @ORM\Column(type="boolean")
 */
protected $active;

/**
 * @ORM\Column(type="text", length="4000", nullable="true")
 */
protected $preview;

/**
 * @ORM\ManyToMany(targetEntity="FeatureType")
 * @ORM\JoinColumn(name="feature_type_id", referencedColumnName="id")
 */
protected $features;

public function __toString()
{
    return $this->getTitle();
}

}

My problem is that when i add FeatureValue in FeatureType then show me error Class “Doctrine\Common\Collections\ArrayCollection is not a valid entity or mapped super class.”

In my project i want FeatureType along with FeatureValue in my Product entity.

suppose in FeatureType two property Size and Colour.Now in FeatureType Size- Three FeatueValue Small,Medium,Large have been given and also suppose in FeatureType Colour- Three FeatureValue Red,Green,Yello have been given.
Now i want to show both the FeatureType along with their FeatureValue in my Product Entity.

So any one tell me how it can be done.I have tried a lot of but not succeed.

  • 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-11T01:13:05+00:00Added an answer on June 11, 2026 at 1:13 am

    In Webmuch\ProductBundle\Entity\FeatureType::__construct you assign an ArrayCollection to $this->name, this is wrong, as this is a ToOne and not a ToMany.

    Just remove this line.

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

Sidebar

Related Questions

I have three entities 'A', 'B', 'C': @Entity public class A implements Serializable {
I'm using Doctrine 2 ORM and I have this problem. I have three Entities,
I have UI automation tests. Tests involve three entities - Data object class -
I have three Doctrine entities: Device, which has a OneToOne relationship with Device\Status, which
I have three Entity Objects. The relationship between these entities is kinda love triangle!
I have three entities as follows: public class EntityA { private Long id; //Getters
Lets say I have a entity model with three entities Item, ItemType and ItemPart.
I have three entities: Country, State and City with the following relationships: When creating
I have three entities: EntityA, EntityB and EntityC connected with to-many relationships. See schema
I have three entities. Author Newspaper Dissertation Newspaper and Dissertation both can have one

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.