Entity Create in Symfony2.6 with Sonata Admin

33 views Asked by At

This is Product Specification which one I am showing on Product details page:-

Square Footage Breakdown

 Total Heated Area:    4,322 sq. ft.
 1st Floor:            2,586 sq. ft.
 2nd Floor:            1,521 sq. ft.
 Apartment:            215 sq. ft.
 Lanai:                715 sq. ft.
 Balcony/Veranda:      323 sq. ft.
 Entry:                236 sq. ft.

Beds/Baths

 Bedrooms:             4
 Full Bathrooms:       4
 Half Bathrooms:       2

Dimensions

 Width:                59' 8"
 Depth:                104' 0"

Garage

 Type:                 Attached
 Area:                 859 sq. ft.
 Details:              3 cars
 Location:             Rear

Foundation Type

 Standard Foundations: Slab

So for this right now I created 3 Entities :-

  1. Specification Category
  2. Specification
  3. Product

Specification Category :-

/**
 * SpecificationCategory
 * @ORM\Table(name="specification_category")
 * @ORM\Entity
 */
class SpecificationCategory
{
/**
 * @var integer
 *
 * @ORM\Column(name="id", type="integer")
 * @ORM\Id
 * @ORM\GeneratedValue(strategy="AUTO")
 */
private $id;

/**
 * @var string
 *
 * @ORM\Column(name="name", type="string", length=255)
 */
private $name;

Specification Entity:-

 /**
  * Specification
  * @ORM\Table(name="specification")
  * @ORM\Entity
  */
class Specification
{
/**
 * @var integer
 *
 * @ORM\Column(name="id", type="integer")
 * @ORM\Id
 * @ORM\GeneratedValue(strategy="AUTO")
 */
private $id;

/**
 * @var \XXX\Bundle\XXXBundle\Entity\SpecificationCategory
 *
 * @ORM\ManyToOne(targetEntity="XXX\Bundle\XXXBundle\Entity\SpecificationCategory")
 * @ORM\JoinColumns({
 * @ORM\JoinColumn(name="specification_category_id", referencedColumnName="id")
 * })
 */
private $specificationCategory;

/**
 * @var string
 *
 * @ORM\Column(name="name", type="string", length=255)
 */
private $name;

/**
 * @var string
 *
 * @ORM\Column(name="description", type="text", nullable=true)
 */
private $description;

/**
 * @var string
 *
 * @ORM\Column(name="area", type="string", length=255, nullable=true)
 */
private $area;

/**
 * @var integer
 *
 * @ORM\Column(name="price", type="integer", length=11, nullable=true)
 */
 private $price;

Product :-

/**
 * Product
 * @ORM\Table()
 */
class Product
{
/**
 * @var integer
 *
 * @ORM\Column(name="id", type="integer")
 * @ORM\Id
 * @ORM\GeneratedValue(strategy="AUTO")
 */
private $id;

/**
 * @ORM\ManyToMany(targetEntity="XXX\Bundle\XXXBundle\Entity\Specification")
 * @ORM\JoinTable(name="product_specification",
 *      joinColumns={@ORM\JoinColumn(name="product_id", referencedColumnName="id")},
 *      inverseJoinColumns={@ORM\JoinColumn(name="specification_id", referencedColumnName="id")}
 *      )
 **/
private $specification;

and right now in admin client need to First Create Specification Category Like :- "Square Footage Breakdown" then create Specification Name like :-"Total Heated Area" and his value one by one.

And this is working perfect.

Problem is Client want to these field's static in Admin...so he can just enter the value while uploading a product instead of adding separate Specification same Name with different Value each time.

Any help will be highly appreciated. Thanks!

0

There are 0 answers