Skip to content

Commit

Permalink
Merged PR 20846: Use helper to get scoped base media URL
Browse files Browse the repository at this point in the history
## What's being changed

Fetching a product image URL for catalog sync, in `UrlFinder`.

## Why it's being changed

The current `getMediaUrl()` method to fetch a media URL for the small image only gets the URL set at default level. This is a problem for some merchants who set the default value to e.g. 'admin.site.com' and then have a firewall on that subdomain.

The `getSmallImageUrl()` helper method now in place is able to get the frontend URL for the supplied product, which is what we need for catalog insight data.

## How to review / test this change

- Set the Base Media URL for your Main Website to be different from the URL set at default
- Set catalog sync to run at Store level
- Run catalog sync
- Confirm that the 'imagePath' fields use the desired base media URL, and that the complete paths output are correct.
- Check that if catalog sync runs at default level, the default base media URL is used

## Notes

- In our testing we've noticed that the modified call outputs an image path with two slashes in it e.g. http://stuff.m19develop.local/media/catalog/product//m/s/msj000t_2.jpg. This appears to be core Magento behaviour and doesn't affect the resolution of the URL.
- Magento will use the base media URL of the first website to which the product belongs. e.g. if product X belongs to websites 2 and 3, the image path will use the base media URL of website 2.

Related work items: #113530
  • Loading branch information
sta1r committed Apr 21, 2020
1 parent e2de81b commit 8f6fd29
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions code/Dotdigitalgroup/Email/Model/Catalog/Urlfinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,8 @@ public function getProductImageUrl($product)
$product = $parentProduct;
}

return Mage::getModel('catalog/product_media_config')
->getMediaUrl($product->getSmallImage());

return Mage::helper('catalog/product')
->getSmallImageUrl($product);
}

/**
Expand Down

0 comments on commit 8f6fd29

Please sign in to comment.