vanilophp / product

Product Module for Vanilo (or any Laravel app)
https://vanilo.io
MIT License
18 stars 8 forks source link

addTaxon undefined #3

Closed victorighalo closed 5 years ago

victorighalo commented 5 years ago

Hi guys, so i just started using this library and i tried to add a Taxon to a product but i got the error :

Call to undefined method Vanilo\Product\Models\Product::addTaxon()

I have to pause my project until this is resolved because i want to build with this library.

fulopattila122 commented 5 years ago

How do you get this error?

fulopattila122 commented 5 years ago

This module is not dependent on the taxon module, so it has no knowledge about taxons. See: https://vanilo.io/docs/0.5/modules-vs-framework

Are you using the entire Vanilo Framework or only selected modules? If the latter, which modules do you use?

To get the list of modules: php artisan concord:modules -a

victorighalo commented 5 years ago

https://vanilo.io/docs/0.5/modules-vs-framework

Yes. I installed the entire framework but i am not using the admin panel.

I got this from the documentation:

Assigning Taxons To A Product:


$product = Product::find(1);
$taxon1 = Taxon::find(1);
$taxon2 = Taxon::find(2);

To assign a single taxon: $product->addTaxon($taxon1);

To assign multiple taxons: $product->addTaxons([$taxon1, $taxon2]);



What I want to do is relate a product to a taxon/s.
fulopattila122 commented 5 years ago

You need to use the (extended) model from the Framework not the one from the Product Module:

use Vanilo\Framework\Model\Product;

$product = Product::find(1);
victorighalo commented 5 years ago
use Vanilo\Framework\Model\Product;

Thanks. so now I'm get the error

Argument 1 passed to Vanilo\Framework\Models\Product::addTaxon() must implement interface Vanilo\Category\Contracts\Taxon
fulopattila122 commented 5 years ago

What are you passing to addTaxon() ?

victorighalo commented 5 years ago

What are you passing to addTaxon() ?

I'm passing a Taxon ID.

fulopattila122 commented 5 years ago

You need to pass a Taxon object as in the example

victorighalo commented 5 years ago

You need to pass a Taxon object as in the example

Oops! I missed that. It works now. Thanks.