Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to extends ShopBillingData #11625

Closed
jbcr opened this issue Jul 7, 2020 · 3 comments
Closed

Unable to extends ShopBillingData #11625

jbcr opened this issue Jul 7, 2020 · 3 comments
Labels
Potential Bug Potential bugs or bugfixes, that needs to be reproduced.

Comments

@jbcr
Copy link
Contributor

jbcr commented Jul 7, 2020

Sylius version affected: 1.7.0+

Description

The overriding of the Sylius\Component\Core\Model\ShopBillingData resource does not work.

This error has been displayed on channel edit action:

Neither the property "complement" nor one of the methods "getComplement()", "complement()", "isComplement()", "hasComplement()", "__get()" exist and have public access in class "Proxies\__CG__\Sylius\Component\Core\Model\ShopBillingData".

complement is a custom property added with my custom class.

Steps to reproduce

Extends the class Sylius\Component\Core\Model\ShopBillingData in your project App\Entity\Channel\ShopBillingData.

Add a new property.

Add this in file config/packages/_sylius.yaml:

sylius_core:
    resources:
        shop_billing_data:
            classes:
                model: App\Entity\Channel\ShopBillingData

Extends the form Sylius\Bundle\CoreBundle\Form\Type\ShopBillingDataType.

Generate database migration and apply-it.

Go to the admin UI and click on the edit link for any channel.

Possible Solution
Redefine the shopBillingData association in the Channel class into your project:

// file: src/Entity/Channel/Channel.php
<?php

declare(strict_types=1);

namespace App\Entity\Channel;

use Doctrine\ORM\Mapping as ORM;
use Sylius\Component\Core\Model\Channel as BaseChannel;

/**
 * @ORM\Entity
 * @ORM\Table(name="sylius_channel")
 */
class Channel extends BaseChannel
{
    /**
     * @var ShopBillingDataInterface|null
     * @ORM\OneToOne(targetEntity="App\Entity\Channel\ShopBillingData")
     * @ORM\JoinColumn(name="shop_billing_data_id", onDelete="CASCADE")
     */
    protected $shopBillingData;
//[...]
}

Or change the target entity to Sylius\Component\Core\Model\ShopBillingDataInterface here : https://github.com/Sylius/Sylius/blob/master/src/Sylius/Bundle/CoreBundle/Resources/config/doctrine/model/Channel.orm.xml#L70

@lchrusciel lchrusciel added the Potential Bug Potential bugs or bugfixes, that needs to be reproduced. label Jul 7, 2020
@stale
Copy link

stale bot commented Oct 12, 2020

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in a week if no further activity occurs. Thank you for your contributions.

@stale stale bot added the Stale Issues and PRs with no recent activity, about to be closed soon. label Oct 12, 2020
@jbcr
Copy link
Contributor Author

jbcr commented Oct 13, 2020

Hi @lchrusciel

Can you reopen this issue, please?

@stale stale bot removed the Stale Issues and PRs with no recent activity, about to be closed soon. label Oct 13, 2020
@jbcr
Copy link
Contributor Author

jbcr commented Oct 21, 2020

In Sylius 1.8.3, I have this error when I run bin/console sylius:install:database command

Expected value of type "App\Entity\Channel\ShopBillingData" for association field "App\Entity\Channel\Channel#$shopBillingData", got "Sylius\Component\Core\Model\ShopBillingData" instead.

lchrusciel added a commit that referenced this issue Oct 29, 2020
This PR was merged into the 1.7 branch.

Discussion
----------

| Q               | A
| --------------- | -----
| Branch?         | 1.7
| Bug fix?        | yes
| New feature?    | no
| BC breaks?      | no
| Deprecations?   | no
| Related tickets | fixes #11625 
| License         | MIT

Fix the relation between Channel and ShopBillingData to allow override the ShopBillingData entity.

Commits
-------

7f68b62 Use ShopBillingDataInterface instead of ShopBillingData
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Potential Bug Potential bugs or bugfixes, that needs to be reproduced.
Projects
None yet
Development

No branches or pull requests

2 participants