我一直在尝试按照此处的指南在我自己的包中派生 Sylius:VariableProductBundle:Variant 的子类。
我创建了一个新包 AcmeVariableProductBundle,它是通过此处概述的方法从 SyliusVariableProduct 包派生的。
按照 Sylius 文档中概述的用于覆盖模型的步骤后,出现以下错误:
Twig_Error_Runtime:在渲染模板期间引发了异常(“在链配置的命名空间 Sylius\Bundle\CartBundle\Entity、FOS\UserBundle\Entity 中找不到类 'Acme\Bundle\VariableProductBundle\Model\Variant', Acme\Bundle\CatalogueBundle\Entity, Sylius\Bundle\SalesBundle\Model, Sylius\Bundle\MoneyBundle\Model, Sylius\Bundle\SettingsBundle\Model, Sylius\Bundle\CartBundle\Model, Sylius\Bundle\ProductBundle\Model, Sylius\ Bundle\VariableProductBundle\Model, Sylius\Bundle\TaxationBundle\Model, Sylius\Bundle\ShippingBundle\Model, Sylius\Bundle\PaymentsBundle\Model, Sylius\Bundle\PromotionsBundle\Model, Sylius\Bundle\AddressingBundle\Model, Sylius\Bundle\ SyliusWebBundle 中的 InventoryBundle\Model、Sylius\Bundle\TaxonomiesBundle\Model、Sylius\Bundle\CoreBundle\Model、FOS\UserBundle\Model"):Frontend/Homepage:main.html.twig 在第 2 行。
我的类定义如下所示:
namespace Acme\Bundle\VariableProductBundle\Model;
use Doctrine\Common\Collections\ArrayCollection;
use Sylius\Bundle\VariableProductBundle\Model\Variant as BaseVariant;
class Variant extends BaseVariant
{
...
}
我在以下位置创建了一个 xml 文件:Acme/Bundle/VariableProductBundle/Resources/config/doctrine/Variant.orm.xml 它看起来像这样:
<?xml version="1.0" encoding="UTF-8" ?>
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
<mapped-superclass name="Acme\Bundle\VariableProductBundle\Model\Variant" table="sylius_variant">
<field name="sku" column="sku" type="string" nullable="true" />
<field name="price" column="price" type="integer" />
<field name="onHand" column="on_hand" type="integer" />
<field name="availableOnDemand" column="available_on_demand" type="boolean"/>
<one-to-many field="images" target-entity="Sylius\Bundle\CoreBundle\Model\VariantImage" mapped-by="variant">
<cascade>
<cascade-all />
</cascade>`
</one-to-many>
</mapped-superclass>
</doctrine-mapping>
app/config/sylius.yml 文件中变量产品的条目是这样的:
sylius_variable_product:
classes:
variant:
model: Acme\Bundle\VariableProductBundle\Model\Variant
form: Sylius\Bundle\CoreBundle\Form\Type\VariantType
谁能告诉我我错过了什么?