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

LinkManagement::getChildren() does not include product ID's (and visibility) #8176

Closed
kanduvisla opened this issue Jan 18, 2017 · 6 comments
Closed
Assignees
Labels
bug report Component: Catalog Fixed in 2.2.x The issue has been fixed in 2.2 release line Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release

Comments

@kanduvisla
Copy link
Contributor

When I'm using the Service Contract Magento\ConfigurableProduct\Api\LinkManagementInterface::getChildren($sku), I get an array of child products, but those products don't seem to be complete. For instance, getId() and getVisibility() returns NULL on those child products.

Preconditions

  1. Magento 2.1.3

Steps to reproduce

Get child products using the LinkManagementInterface service contract and try to get ID and visibility of the results:

public function __construct(
    LinkManagementInterface $linkManagement
) {
    $this->linkManagement = $linkManagement;
}

public function example()
{
    $childProducts = $this->linkManagement->getChildren('SKU_OF_CONFIGURABLE');
    foreach ($childProducts as $childProduct) {
        var_dump($childProduct->getId());
        var_dump($childProduct->getVisibility());
    }
}

Expected result

I should get the ID and Visibility parameter of the child products

Actual result

I get NULL and NULL

Workaround

A possible workaround is to explicitly load the product, but this causes some overhead:

foreach ($childProducts as $childProduct) {
    // Use ProductRepositoryInterface to explicitly load the product:
    $childProduct = $this->productRepository->get($childProduct->getSku());
    var_dump($childProduct->getId());
    var_dump($childProduct->getVisibility());
}
@KrystynaKabannyk
Copy link

Hello @kanduvisla, could you please describe steps to reproduce in more detains?
Thank you!

@kanduvisla
Copy link
Contributor Author

@KrystynaKabannyk I think my steps are pretty self-explanatory. Just create an instance of Magento\ConfigurableProduct\Api\LinkManagementInterface and call the getChildren()-method. But if you insist:

Step 1: Create a configurable product with some simples.
Step 2: Create a class with at least this structure:

class LinkManagementBugExample
{
    public function __construct(
        LinkManagementInterface $linkManagement
    ) {
        $this->linkManagement = $linkManagement;
    }

    public function example(string $sku)
    {
        $childProducts = $this->linkManagement->getChildren($sku);
        foreach ($childProducts as $childProduct) {
            var_dump($childProduct->getId());
            var_dump($childProduct->getVisibility());
        }
    }
}

Step 3: Run the example()-method with the SKU of the configurable.

The resulted output is 2 times NULL, rather than the ID and the visibility of the child product.

@kanduvisla
Copy link
Contributor Author

kanduvisla commented Feb 28, 2017

Any updates on this issue? I ran into it again today. As a workaround I have to include the product resource as a dependency:

$this->productResource->getIdBySku($child->getSku())

@kanduvisla
Copy link
Contributor Author

Still no update on this? Can at least anyone confirm this issue? Or is it just me?

@magento-engcom-team magento-engcom-team added 2.1.x bug report Component: Catalog Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed and removed G1 Passed labels Sep 5, 2017
@magento-engcom-team magento-engcom-team added the Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed label Oct 6, 2017
@magento-engcom-team
Copy link
Contributor

@kanduvisla, thank you for your report.
We've created internal ticket(s) MAGETWO-81151 to track progress on the issue.

@magento-engcom-team magento-engcom-team added 2.2.x Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release labels Oct 11, 2017
@nmalevanec nmalevanec self-assigned this Dec 11, 2017
@okorshenko
Copy link
Contributor

Hi @kanduvisla
The issue has been fixed and delivered in 2.2-develop branch. Will be available with upcoming patch release.

@okorshenko okorshenko added the Fixed in 2.2.x The issue has been fixed in 2.2 release line label Dec 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report Component: Catalog Fixed in 2.2.x The issue has been fixed in 2.2 release line Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release
Projects
None yet
Development

No branches or pull requests

7 participants