File tree 1 file changed +27
-0
lines changed
app/code/Magento/Sitemap/Controller/Adminhtml/Sitemap 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change 6
6
*/
7
7
namespace Magento \Sitemap \Controller \Adminhtml \Sitemap ;
8
8
9
+ use Magento \Backend \App \Action ;
10
+ use Magento \Store \Model \App \Emulation ;
11
+
9
12
class Generate extends \Magento \Sitemap \Controller \Adminhtml \Sitemap
10
13
{
14
+ /** @var \Magento\Store\Model\App\Emulation $appEmulation */
15
+ private $ appEmulation ;
16
+
17
+ /**
18
+ * Generate constructor.
19
+ * @param Action\Context $context
20
+ * @param \Magento\Store\Model\App\Emulation $appEmulation
21
+ */
22
+ public function __construct (
23
+ Action \Context $ context ,
24
+ Emulation $ appEmulation
25
+ ) {
26
+ $ this ->appEmulation = $ appEmulation ;
27
+ parent ::__construct (
28
+ $ context
29
+ );
30
+ }
31
+
11
32
/**
12
33
* Generate sitemap
13
34
*
@@ -23,7 +44,13 @@ public function execute()
23
44
// if sitemap record exists
24
45
if ($ sitemap ->getId ()) {
25
46
try {
47
+ //We need to emulate to get the correct frontend URL for the product images
48
+ $ this ->appEmulation ->startEnvironmentEmulation ($ sitemap ->getStoreId (),
49
+ \Magento \Framework \App \Area::AREA_FRONTEND ,
50
+ true
51
+ );
26
52
$ sitemap ->generateXml ();
53
+ $ this ->appEmulation ->stopEnvironmentEmulation ();
27
54
28
55
$ this ->messageManager ->addSuccess (
29
56
__ ('The sitemap "%1" has been generated. ' , $ sitemap ->getSitemapFilename ())
You can’t perform that action at this time.
0 commit comments