Recent Topics

How to override product model?



  • Hi,

    I've created a couple of new packages to extend the product admin section, however I can not seem to override the product model.

    I am just trying to add a new relationship.

    I have

    $this->app->concord->registerModel(
        ProductContract::class, Product::class
    );
    

    in my package service provider, but still not seeing the relationship.



  • Hi,

    Please go through with following link -https://devdocs.bagisto.com/override-core-model.html.



  • Hi Rahul,

    That's exactly what I mentioned I had done in my original comment, yet it still would not work.



  • In your package, create your model.
    In this model, extend that model to whom, you want to extend.

    <?php

    namespace App\Http;

    use Webkul\Product\Models\Product as ProductBaseModel;

    class Product extends ProductBaseModel
    {

    }

    In your service provider register your model with contract of model.

    $this->app->concord->registerModel(\Webkul\Product\Contracts\Product::class, \App\Http\Product::class);

    Thanks
    Rahul Shukla


Log in to reply