Skip to content
This repository was archived by the owner on Dec 19, 2019. It is now read-only.

Conversation

VoronoyAlexandr
Copy link
Contributor

Description (*)

PR for issue #239 Fix resolving of image placeholder for Product without images.
Changed area to "frontend" instead "graphql" for placeholder asset.

Fixed Issues (if relevant)

  1. [BugFix] Fix resolving of image placeholder for Product without images #239: Fix resolving of image placeholder for Product without images

Manual testing scenarios (*)

Request:

{
  products (search: "Test") {
    
    items {
        id
        name
      small_image {
        url
      }
    }
  }
}

Response:

{
  "data": {
    "products": {
      "items": [
        {
          "id": 1201,
          "name": "Test",
          "small_image": {
            "url": "http://graphql-ce.loc/static/version1541944966/frontend/Magento/luma/en_US/Magento_Catalog/images/product/placeholder/small_image.jpg"
          }
        }
      ]
    }
  }
}

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds on Travis CI are green)

@@ -71,7 +79,15 @@ private function getImageUrl(string $imageType, ?string $imagePath): string
$image = $this->productImageFactory->create();
$image->setDestinationSubdir($imageType)
->setBaseFile($imagePath);
$imageUrl = $image->getUrl();

$imageUrl = $image->isBaseFilePlaceholder()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@naydav could we get someone to test this solution please?

Copy link
Contributor

@naydav naydav Nov 15, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already have test, need just unskip it and add a few asserts

@naydav
Copy link
Contributor

naydav commented Nov 15, 2018

Also, need to unskip test
\Magento\GraphQl\Catalog\ProductImageTest::testProductWithoutBaseImage
and add a few asserts

@naydav
Copy link
Contributor

naydav commented Nov 19, 2018

@VoronoyAlexandr
Pls, need to add additional asserts to unskiped API functional test

/**
* @var PlaceholderProvider
*/
private $_placeholderProvider;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't use prefix _ for variables


/**
* Url constructor.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra comment

$imageUrl = $image->getUrl();
return $imageUrl;

if ($image->isBaseFilePlaceholder()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to cover this logic with API-functional test

use Magento\Store\Model\StoreManagerInterface;

/**
* Class Placeholder
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Provide clear dockblocks for all of classes

* Class Placeholder
* @package Magento\CatalogGraphQl\Model\Resolver\Products\DataProvider\Image
*/
class Placeholder
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this class has a lot of responsibility (like helper in Magento 1)

@@ -51,7 +51,6 @@ public function testProductWithBaseImage()
*/
public function testProductWithoutBaseImage()
{
$this->markTestIncomplete('https://github.com/magento/graphql-ce/issues/239');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to add additional logic for checking of placeholders

}

return $this->_assetRepository->createAsset(
"Magento_Catalog::images/product/placeholder/{$imageType}.jpg",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to check behavior if I changed default placeholder on some custom value via configuration

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's done above
if ($imageAsset->getFilePath()) {
return $imageAsset->getUrl();
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need config fixture to check this

@naydav naydav changed the title Fix area for image placeholder in graphql response. [BugFix] Fix area for image placeholder in graphql response. Dec 12, 2018
@naydav naydav modified the milestone: Release: 2.3.1 Dec 12, 2018
@naydav
Copy link
Contributor

naydav commented Jan 23, 2019

Hello @VoronoyAlexandr,
We still need some changes to finish the PR, will you continue progress?
Thank you

Please let me know if you need any assistance.

@VitaliyBoyko
Copy link
Contributor

Closing this one due to inactivity.

@ghost
Copy link

ghost commented Feb 12, 2019

Hi @VoronoyAlexandr, thank you for your contribution!
Please, complete Contribution Survey, it will take less than a minute.
Your feedback will help us to improve contribution process.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants