magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.55k stars 9.32k forks source link

Cron gets wrong base media URL #9111

Closed MrDaar closed 6 years ago

MrDaar commented 7 years ago

Preconditions

  1. Magento: 2.1.5
  2. PHP: 7

Steps to reproduce

  1. Set up Magento with pub folder as webroot
  2. Set email logo in Content > Design > Configuration > Edit > Transactional Emails > Logo Image
  3. Have a cron (custom) send an email

Expected result

  1. Email is received with all images showing.

Actual result

  1. No images show.
  2. Path to images contain: "/pub/"

The image above is set in config, but the issue will also happen for product image urls generated by:

return $this->_imageHelper->init($product, $type, $attributes)
            ->setImageFile($imageFile)->resize(208, 260)->save()->getUrl();

or images included with directives:

<img src="{{media url="wysiwyg/emails/mailer-footer.png"}}" alt="{{trans "Thank you, %store_name" store_name=$store.getFrontendName()}}!" />

You can force the media url in config: Stores > Configuration > Web But that shouldn't be necessary.

Magento\Store\Model\Store->getBaseUrl(...) returns wrong value.

scottsb commented 7 years ago

We're experiencing the same issue with the built-in product stock alert module, which generates its emails via cron.

scottsb commented 7 years ago

Just noted that this is a duplicate of #8868.

scottsb commented 7 years ago

Finally found workaround: http://magento.stackexchange.com/a/167869/567

MrDaar commented 7 years ago

@scottsb

You can force the media url in config: Stores > Configuration > Web

So if you set the config value in control centre it'll also be fine.

MrDaar commented 7 years ago

Base URL for User Media Files {{unsecure_base_url}}media/ Secure Base URL for User Media Files {{secure_base_url}}media/

(edited)

scottsb commented 7 years ago

I attempted that, but it didn't seem to resolve the issue for me. Either I did something wrong, forgot to clear my cache or it's another issue with single-store mode (maybe related to #8137).

hostep commented 7 years ago

We experienced the same problem, where the media paths in the generated sitemap.xml file were incorrect when the sitemap.xml was generated by the cronjob, if you generate it manually, the paths were correct.

Solution from @MrDaar fixed it for us, but it shouldn't contain the forward slash in the middle, it should be:

magento-engcom-team commented 7 years ago

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

magento-engcom-team commented 6 years ago

Hi @MrDaar We are now closing this as a duplicate of https://github.com/magento/magento2/issues/8868

Thank you for participation

Axel29 commented 6 years ago

Hi,

Thank you for your solutions, I've been debugging this problem for a moment now! The only thing is that I also had to change the web/(un)secure/base_static_url paths to {{(un)secure_base_url}}static/ to make it work.

jajajaime commented 6 years ago

I can corroborate that setting the base_static_url path to {{(un)secure_base_url}}static/ solves the issue for me. The config that needs to be set probably depends if your images are in media or static folder.

nahuelsanchez commented 6 years ago

@magento-engcom-team give me 2.3-develop instance

magento-engcom-team commented 6 years ago

Hi @nahuelsanchez. Thank you for your request. I'm working on Magento 2.3-develop instance for you

magento-engcom-team commented 6 years ago

Hi @nahuelsanchez, here is your Magento instance. Admin access: https://i-9111-2-3-develop.engcom.dev.magento.com/admin Login: admin Password: 123123q Instance will be terminated in up to 3 hours.

scottsb commented 6 years ago

WHAT IS THIS MAGIC?

Naeemakhter1999 commented 4 years ago

In have to add cron process in extension ,which can shown in a cron_schedule tabel. how can i add? in Magento1 Googleshopping Extension.

hareshpatel commented 3 years ago

Hello same issue can you plz help me what is step resolve this issue