如何在OroCrm中覆盖一个包

时间:2017-07-04 08:05:17

标签: symfony overrides orocrm

我正在尝试(未成功)覆盖特定的捆绑类。 我想要覆盖的是:

奥罗\捆绑\ MagentoBundle \实体\库\ CustomerRepository

为此,我创建了我的包

namespace Kiwee\Bundle\MnhBundle;

use Symfony\Component\HttpKernel\Bundle\Bundle;

class MnhMagentoBundle extends Bundle {

    public function getParent() {
        return 'OroMagentoBundle';
    }
}

我添加了bundles.yml

bundles:
    - Kiwee\Bundle\MnhBundle\MnhMagentoBundle

到目前为止,非常好..捆绑包已加载。 现在,我似乎无法找到关于如何覆盖上述类的任何工作示例。

我尝试使用与我想要覆盖的类相同的相对路径创建一个文件,但它不起作用。

namespace Kiwee\Bundle\MnhBundle\Entity\Repository;

use Oro\Bundle\MagentoBundle\Entity\Repository\CustomerRepository as BaseCustomerRepository;

class CustomerRepository extends BaseCustomerRepository
{
    public function calculateLifetimeValue(Customer $customer)
    {
        // [... here is my custom logic for this method ...]

    }
}

我遇到的第一个问题是"客户"与原始类中的类型不同。 第二个是,即使通过声明完整的类路径来修复它,也不会在原始路径时使用此方法。 任何提示?

非常感谢

1 个答案:

答案 0 :(得分:0)

将其覆盖为常规教条存储库。 请参阅此回答https://stackoverflow.com/a/37486268/2119164它应该可以解决您的问题。