title: How to display the database tables in twig using symfony 4?
body: <p>I am using relational database for fetching the category for the newproduct table
  I can fetch the category table using these commands</p>
  
  <pre><code>{% for category in category %}
               {{ category.category }}       
          {% endfor %}
  </code></pre>
  
  <p>But when i try to display the newproduct table in database It throws error</p>
  
  <pre><code>&lt;div class="table-responsive"&gt;  
  &lt;table class="table table-condensed" border="1" cellpadding="10"&gt;
      tbody&gt;
      &lt;tr&gt;
      &lt;th&gt;&lt;h4&gt; ID&lt;/h4&gt;&lt;/th&gt;
      &lt;th&gt;&lt;h4&gt; category&lt;/h4&gt;&lt;/th&gt;
      &lt;th&gt;&lt;h4&gt;  product_code&lt;/h4&gt;&lt;/th&gt;
      &lt;th&gt;&lt;h4&gt; product_name&lt;h4&gt;&lt;/th&gt;
      &lt;th&gt;&lt;h4&gt; quantity&lt;/h4&gt;&lt;/th&gt;
      &lt;th&gt;&lt;h4&gt; price&lt;/h4&gt;&lt;/th&gt;
      &lt;th&gt;&lt;h4&gt; gst &lt;/h4&gt;&lt;/th&gt;
      &lt;th&gt;&lt;h4&gt; hsn_code&lt;/h4&gt;&lt;/th&gt;
      &lt;th&gt;&lt;h4&gt; product_metric &lt;/h4&gt;&lt;/th&gt;
      &lt;th&gt;&lt;h4&gt; product_dimension &lt;/h4&gt;&lt;/th&gt;
      strong text&lt;th&gt;&lt;h4&gt; supplier_name&lt;/h4&gt;&lt;/th&gt;
  
  
              &lt;/tr&gt;
  
              {%  for newproduct in newproduct %}
              &lt;tr&gt; 
                  &lt;td&gt; {{ newproduct.ID}}        &lt;/td&gt;
                  {% for category in category %}
                  &lt;td&gt; {{ category.category }}       &lt;/td&gt;
                  {% endfor %
                  &lt;td&gt; {{ newproduct.product_code}}       &lt;/td&gt;
                  &lt;td&gt; {{ newproduct.product_name}}       &lt;/td&gt;
                  &lt;td&gt; {{ newproduct.quantity }}          &lt;/td&gt;
                  &lt;td&gt; {{ newproduct.price }}             &lt;/td&gt;
                  &lt;td&gt; {{ newproduct.gst }}               &lt;/td&gt;
                  &lt;td&gt; {{ newproduct.hsn_code }}           &lt;/td&gt;
                  &lt;td&gt; {{ newproduct.product_metric }}     &lt;/td&gt;
                  &lt;td&gt; {{ newproduct.product_dimension }}  &lt;/td&gt;
                  &lt;td&gt; {{ newproduct.supplier_name }}      &lt;/td&gt;
  
  
               &lt;/tr&gt;
              {% endfor %}
  
          &lt;/tbody&gt;
      &lt;/table&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p><strong>Error:</strong></p>
  
  <p>Neither the property "product_code" nor one of the methods "product_code()", "getproduct_code()"/"isproduct_code()"/"hasproduct_code()" or "__call()" exist and have public access in class "App\Entity\NewProduct".</p>
  
  <p>In Entity</p>
  
  <pre><code>&lt;?php
  
  namespace App\Entity;
  
  use Doctrine\ORM\Mapping as ORM;
  
  /**
   * @ORM\Entity(repositoryClass="App\Repository\NewProductRepository")
   */
  class NewProduct
  {
      /**
       * @ORM\Id()
       * @ORM\GeneratedValue()
       * @ORM\Column(type="integer")
       */
      private $id;
  
      /**
       * @ORM\ManyToOne(targetEntity="App\Entity\Category", inversedBy="newProducts")
       * @ORM\JoinColumn(nullable=false)
       */
      private $category;
  
      /**
       * @ORM\Column(type="string", length=50)
       */
      private $product_code;
  
      /**
       * @ORM\Column(type="string", length=50)
       */
      private $product_name;
  
      /**
       * @ORM\Column(type="integer")
       */
      private $quantity;
  
      /**
       * @ORM\Column(type="float")
       */
      private $price;
  
      /**
       * @ORM\Column(type="float")
       */
      private $gst;
  
      /**
       * @ORM\Column(type="integer")
       */
      private $hsn_code;
  
      /**
       * @ORM\Column(type="integer")
       */
      private $product_metric;
  
      /**
       * @ORM\Column(type="integer", nullable=true)
       */
      private $product_dimension;
  
      /**
       * @ORM\Column(type="string", length=50)
       */
      private $supplier_name;
  
      public function getId()
      {
          return $this-&gt;id;
      }
  
      public function getCategory(): ?Category
      {
          return $this-&gt;category;
      }
  
      public function setCategory(?Category $category): self
      {
          $this-&gt;category = $category;
  
          return $this;
      }
  
      public function getProductCode(): ?string
      {
          return $this-&gt;product_code;
      }
  
      public function setProductCode(string $product_code): self
      {
          $this-&gt;product_code = $product_code;
  
          return $this;
      }
  
      public function getProductName(): ?string
      {
          return $this-&gt;product_name;
      }
  
      public function setProductName(string $product_name): self
      {
          $this-&gt;product_name = $product_name;
  
          return $this;
      }
  
      public function getQuantity(): ?int
      {
          return $this-&gt;quantity;
      }
  
      public function setQuantity(int $quantity): self
      {
          $this-&gt;quantity = $quantity;
  
          return $this;
      }
  
      public function getPrice(): ?float
      {
          return $this-&gt;price;
      }
  
      public function setPrice(float $price): self
      {
          $this-&gt;price = $price;
  
          return $this;
      }
  
      public function getGst(): ?float
      {
          return $this-&gt;gst;
      }
  
      public function setGst(float $gst): self
      {
          $this-&gt;gst = $gst;
  
          return $this;
      }
  
      public function getHsnCode(): ?int
      {
          return $this-&gt;hsn_code;
      }
  
      public function setHsnCode(int $hsn_code): self
      {
          $this-&gt;hsn_code = $hsn_code;
  
          return $this;
      }
  
      public function getProductMetric(): ?int
      {
          return $this-&gt;product_metric;
      }
  
      public function setProductMetric(int $product_metric): self
      {
          $this-&gt;product_metric = $product_metric;
  
          return $this;
      }
  
      public function getProductDimension(): ?int
      {
          return $this-&gt;product_dimension;
      }
  
      public function setProductDimension(?int $product_dimension): self
      {
          $this-&gt;product_dimension = $product_dimension;
  
          return $this;
      }
  
      public function getSupplierName(): ?string
      {
          return $this-&gt;supplier_name;
      }
  
      public function setSupplierName(string $supplier_name): self
      {
          $this-&gt;supplier_name = $supplier_name;
  
          return $this;
      }
      public function __toString()
     {
      return (string) $this-&gt;getCategory();
     }
  }
  </code></pre>