override AttributeOption model results in whoops, when opening attribute edit page
-
I extended AttributeOption model as shown in https://devdocs.bagisto.com/1.x/advanced/override-core-model.html
I just extended the fillable property like so:<?php namespace Vendor\App\Models; use Webkul\Attribute\Models\AttributeOption as AttributeOptionBaseModel; class AttributeOption extends AttributeOptionBaseModel { protected $fillable = [ 'admin_name', 'swatch_value', 'sort_order', 'attribute_id', 'uuid' ]; }
and registered the model in the respective ServiceProvider in Vendor/App/Providers like so:
$this->app->concord->registerModel( \Webkul\Attribute\Contracts\AttributeOption::class, \Vendor\App\Models\AttributeOption::class );
when I now try to open /shop/admin/catalog/attributes/edit/[some_attribute_id] I get:
Class 'Vendor\App\Models\AttributeOptionTranslation' not found (View: /var/www/html/shop/packages/Webkul/Admin/src/Resources/views/catalog/attributes/edit.blade.php)
Of course, that file does not exist. I only want to override AttributeOption, not AttributeOptionTranslation. Is this a bug, which needs to be solved at bagisto code level? Is there a workaround to let bagisto still use their AttributeOptionTranslation class?
-
Hi @Martin,
The problem seems to be with your composer autoload. As the class is not able to recognize.
-
Hi @devansh-webkul, thanks for the answer, but there is no class \Vendor\App\Models\AttributeOptionTranslation. I don't want to override AttributeOptionTranslation, I only want to override \Webkul\Attribute\Models\AttributeOption with \Vendor\App\Models\AttributeOption. That is the problem, Laravel thinks \Vendor\App\Models\AttributeOptionTranslation exists, but of course it doesn't, it is not created or intended to be created as it is not registered via concord.
EDIT: also https://devdocs.bagisto.com/1.x/advanced/override-core-model.html does not mention to change the composer.json anywhere. Also the package `"Vendor\App\": "packages/Vendor/App/src" is inside the composer.json section "psr-4", so all classes inside should be considered by autoload already. I really do not understand your reply
-
Hi,
I just want to say run
composer dump-autoload
. Because this seems to be an issue with the autoloading. -
ah, thank you very much. Now I understand, and yes that does the trick! Wow, that is really unintuitive, at least for a php/Laravel newbie like me. Maybe one can add this hint to run dump-autoload in the override core model docs?
-
Hi, @Martin,
Thanks for the update.
Also, if you like our support, you may give us the review here:- https://www.trustpilot.com/review/bagisto.com
That would be grateful for us.
Thanks & Regards,
Bagisto Team