loevgaard / SyliusBrandPlugin

A Sylius plugin to enable the association of brands to your products
MIT License
30 stars 29 forks source link

Getting <<Variable "remote_url" does not exist>> in a completely different file #58

Open flindblom-ohmy opened 5 years ago

flindblom-ohmy commented 5 years ago

Hi, it's me again, I'm soo close to getting this working now.

remote_url_does_not_exist

I would have assumed that this was my fault somehow if it wasn't for the fact that this error is mentioned in your documentation. Albeit in a completely different file. Now I'm getting this error in one of the stock (vendor) templates, not in something I modified myself.

Now, I have barely started to learn the inner workings of Sylius so I may be completely off target here, but the documentation mentions that you inject something globally. Could your "remote_url" be conflicting with some other "remote_url"?

These are the relevant packages in my composer.json:

"require": { "php": "^7.2", "loevgaard/sylius-brand-plugin": "^2.0", "sylius/shop-api-plugin": "^1.0@RC", "sylius/sylius": "~1.5.0",

igormukhingmailcom commented 5 years ago

Hi. This error occurs when you haven't override form template (and so not defined that remote_url in field's options) with some autocomplete field.

Follow docs and override templates as mentioned there and error will gone.

UPD As far as you migrating from previous version, you should check that you removed {{ form_row(form.brand) }} line from your templates/bundles/SyliusAdminBundle/views/Product/Tab/_details.html.twig. As far as that field now injecting to template automatically with all required parameters (proper remote_url).

flindblom-ohmy commented 5 years ago

Thank you for replying @igormukhingmailcom ! I did follow the instructions as best I could but I'm missing something.

Do I have to copy the files in SyliusBrandPlugin/src/Resources/views to... somewhere? Because that is never specified in the installation instructions.

I don't have a templates/bundles/SyliusAdminBundle/views/Product folder. Should I create it and add the files from the SyliusBrandPlugin repo as mentioned above?

flindblom-ohmy commented 5 years ago

Probably unrelated but I'm throwing it in here anyway. This bit under "Configure":

sylius_product: resources: product: classes: model: App\Model\Product repository: App\Doctrine\ORM\ProductRepository

Gives me "Warning: class_implements(): Class App\Doctrine\ORM\ProductRepository does not exist and could not be loaded"

Not adding that bit to services.yaml instead lands me on the previous remote_url error.

flindblom-ohmy commented 5 years ago

Alright, new day, new attempts.

As previously stated I don't have a templates/bundles/SyliusAdminBundle/views/Product/Tab/_details.html.twig template at all, I'm not upgrading per se, I just installed the older version because my composer didn't have minimum-stability set to dev, so it gave me 1.3 (I think) until I manually requested 2.0.

So, I've uninstalled the plugin, installed 2.0 from scratch, following all the steps in the documentation, and if I do everything then I get the "Warning: class_implements()" error mentioned above.

If I skip that part of the installation instructions and don't edit config/services.yaml then I get to the remote_url error.

Next I'm going to install a fresh Sylius in an empty directory and then try to follow the instructions step by step again, if I get the same error then I can be reasonably sure that all this is not my fault.

flindblom-ohmy commented 5 years ago

So, the first problem is that

composer require loevgaard/sylius-brand-plugin

gives you a version of the plugin that is not compatible with the documentation, you really should change it to

composer require loevgaard/sylius-brand-plugin:^2.0

then at least users won't end up where I ended up. Also include in the instructions that they need to add

"minimum-stability": "dev",

to their composer.json.

Now, fresh install.

Under step 4, in the example code, the namespace for Product is App\Entity\Product in the latest version.

In step 5 I get Warning: class_implements(): Class App\Model\Product does not exist and could not be loaded (when trying to run migrations)

This is because the instructions in step 4 under "Configure" specifies

model: App\Model\Product

which should be

model: App\Entity\Product\Product

After that the plugin works. So I'm guessing the template woes I'm having in my actual project is due to something else.

Thanks for reading my rants.