Skip to content

Fixes problem with wrong image URL in sitemap #24605

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

Merged

Conversation

krisdante
Copy link
Contributor

@krisdante krisdante commented Sep 15, 2019

Description (*)

Problem was caused by the wrong context of generation. It was adminhtml
and for this area URL for selected image sizes are not defined (as
those sizes are not defined).
Fixed by using Emulation and stwiched to Frontend area for Sitemap generation.

Fixed Issues (if relevant)

  1. sitemap image URLs has wrong cache path #24484: sitemap image URLs has wrong cache path
    2.(indirectly) Images added to sitemap are "404 Not Found" on Nginx [Magento 2.1.0] #5321: Images added to sitemap are "404 Not Found" on Nginx [Magento 2.1.0]
    3.(indirectly) XML Sitemap refers to non-watermarked images #4511: XML Sitemap refers to non-watermarked images

Manual testing scenarios (*)

  1. Create 2 stores
  2. Add at least one product to each of those store
  3. Add at least one image to each of the products
  4. Create Sitemap for one of the stores.
  5. Generate sitemap (form admin)
  6. Open sitemap and check the URL of the image in the feed.
    It needs to be valid (not 404) and egual to url of large image from the storefront.

Questions or comments

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 are green)

Problem was caused by wrong context of generation. It was adminhtml
and for this area URL for selected image sizes are not defined (as
those sizes are not defined).
Fixed by using Emulation.
@m2-assistant
Copy link

m2-assistant bot commented Sep 15, 2019

Hi @krisdante. Thank you for your contribution
Here is some useful tips how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento give me test instance - deploy test instance based on PR changes
  • @magento give me 2.3-develop instance - deploy vanilla Magento instance

For more details, please, review the Magento Contributor Guide documentation.

@krisdante
Copy link
Contributor Author

FIxes #5321

@krisdante
Copy link
Contributor Author

Fixes #4511

@kalpmehta kalpmehta self-assigned this Sep 15, 2019
@magento-engcom-team
Copy link
Contributor

Hi @kalpmehta, thank you for the review.
ENGCOM-5844 has been created to process this Pull Request
✳️ @kalpmehta, could you please add one of the following labels to the Pull Request?

Label Description
Auto-Tests: Covered All changes in Pull Request is covered by auto-tests
Auto-Tests: Not Covered Changes in Pull Request requires coverage by auto-tests
Auto-Tests: Not Required Changes in Pull Request does not require coverage by auto-tests

@engcom-Delta
Copy link
Contributor

✔️ QA passed

@engcom-Foxtrot engcom-Foxtrot self-assigned this Sep 17, 2019
@sidolov sidolov added the Auto-Tests: Not Covered Changes in Pull Request requires coverage by auto-tests label Sep 17, 2019
@kalpmehta
Copy link
Contributor

@krisdante Can you add automated tests please?

@m2-assistant
Copy link

m2-assistant bot commented Sep 20, 2019

Hi @krisdante, 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.

@magento-engcom-team magento-engcom-team added this to the Release: 2.3.4 milestone Sep 20, 2019
@manishmaharjan
Copy link

@krisdante , It seems like it works when sitemap is manually generated, but when sitemap is generated by a scheduler it seems to still take placeholder image. Has this issue also been addressed? Thanks

@krisdante
Copy link
Contributor Author

@manishmaharjan This is different piece of code. Please add a new issue. You can mention me there and I will fix it.

@edijsvanags
Copy link

Does not $this->appEmulation->stopEnvironmentEmulation(); should also be triggered in catches if an exception is thrown ?

It should, however, you can use the finally method, which will be executed each time.

try { $this->emulation->startEnvironmentEmulation( $sitemap->getStoreId(), \Magento\Framework\App\Area::AREA_FRONTEND, true ); $sitemap->generateXml(); ...... } catch (\Exception $e) { ...... } finally { $this->emulation->stopEnvironmentEmulation(); }

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

Successfully merging this pull request may close these issues.