1
votes

I am working with sonata E-Commerce Bundle. After installing the bundle and it's dependencies successfully I get the admin dashboard page as expected.

However when I click on "Add new" option for the Product I get a blank block, with no fields or buttons. Here is the screenshot enter image description here

But this is not it. when I click on the "List" option for Product, I get following error

An exception occurred while executing 'SELECT count(DISTINCT p0_.id) AS sclr_0 FROM product__product p0_ LEFT JOIN product__product_category p1_ ON p0_.id = p1_.product_id LEFT JOIN classification__category c2_ ON p1_.category_id = c2_.id LEFT JOIN product__product_collection p3_ ON p0_.id = p3_.product_id LEFT JOIN classification__collection c4_ ON p3_.collection_id = c4_.id WHERE p0_.product_type IN ()':

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1

On scouring the internet I found a post on github with the same problem (https://github.com/sonata-project/ecommerce/issues/9). I followed the suggested solution ie.

  • Created a product type (Bowl) using php app/console sonata:product:generate Bowl sonata.ecommerce_demo.product.bowl
  • Imported the resource
  • Created app/config/sonata/sonata_product.yml as shown in the documentation
  • And finally made the Bowl class inherit the Product class

Still I get the same error.

Here is my Bowl.php

<?php

/*
 * This file is part of the <name> project.
 *
 * (c) <yourname> <youremail>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Application\Sonata\ProductBundle\Entity;

//use Sonata\ProductBundle\Entity\Product as Product;

/**
 * This file has been generated by the Sonata product generation command ( https://sonata-project.org/ )
 *
 * References :
 *   working with object : http://www.doctrine-project.org/projects/orm/2.0/docs/reference/working-with-objects/en
 *
 * @author <yourname> <youremail>
 */
class Bowl extends Product {

    /**
     * @var integer $id
     */
    protected $id;

    /**
     * Get id
     *
     * @return integer $id
     */
    public function getId() {
        return $this->id;
    }

    /**
     * @param int $id
     */
    public function setId($id) {
        $this->id = $id;
    }

}

Any ideas?

1

1 Answers

1
votes

Figured it out:

Create a Product type (http://sonata-project.org/bundles/ecommerce/master/doc/reference/tutorials/create-product.html) php app/console sonata:product:generate Bowl sonata.ecommerce_demo.product.bowl

import all resources

This being done, edit the src/Application/Sonata/ProductBundle/Entity/Bowl.php to make it inherits the Product class.

class Bowl extends Product {

}

Note: don't forget to import sonata_product.yml(which isn't mentioned in the doccumentation). Add - { resource: sonata/sonata_product.yml } to your config.yml