Sonata产品列表错误(Sonata电子商务套装)

时间:2016-10-10 17:59:51

标签: symfony sonata

我正在使用奏鸣曲电子商务套装。成功安装捆绑包及其依赖项后,我按预期获得了管理仪表板页面。

然而,当我点击产品的“添加新”选项时,我得到一个空白区块,没有字段或按钮。这是截图 enter image description here

但这不是它。当我点击Product的“List”选项时,我收到以下错误

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]:语法错误或访问冲突:1064 SQL语法中有错误;检查与MySQL服务器版本对应的手册,以便在第1行的')'附近使用正确的语法

在网上搜索时,我在github上发现了一个同样问题的帖子(https://github.com/sonata-project/ecommerce/issues/9)。我按照建议的解决方案即。

  • 使用php app/console sonata:product:generate Bowl sonata.ecommerce_demo.product.bowl
  • 创建了产品类型(Bowl)
  • 导入资源
  • 如文档
  • 中所示创建app/config/sonata/sonata_product.yml
  • 最后让Bowl类继承了Product类

我仍然得到同样的错误。

这是我的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;
    }

}

有什么想法吗?

1 个答案:

答案 0 :(得分:1)

想出来:

创建产品类型(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

导入所有资源

这样做,编辑src / Application / Sonata / ProductBundle / Entity / Bowl.php使其继承Product类。

class Bowl扩展Product {

}

注意:不要忘记导入sonata_product.yml(在doccumentation中没有提到)。将 - {resource:sonata / sonata_product.yml}添加到config.yml