diff --git a/app/code/Magento/Contact/Model/Mail.php b/app/code/Magento/Contact/Model/Mail.php
index 9a1f1ff8a2063..d63efbbca573b 100644
--- a/app/code/Magento/Contact/Model/Mail.php
+++ b/app/code/Magento/Contact/Model/Mail.php
@@ -6,7 +6,9 @@
namespace Magento\Contact\Model;
use Magento\Framework\Mail\Template\TransportBuilder;
+use Magento\Framework\App\ObjectManager;
use Magento\Framework\Translate\Inline\StateInterface;
+use Magento\Store\Model\StoreManagerInterface;
class Mail implements MailInterface
{
@@ -26,18 +28,29 @@ class Mail implements MailInterface
private $inlineTranslation;
/**
+ * @var StoreManagerInterface
+ */
+ private $storeManager;
+
+ /**
+ * Initialize dependencies.
+ *
* @param ConfigInterface $contactsConfig
* @param TransportBuilder $transportBuilder
* @param StateInterface $inlineTranslation
+ * @param StoreManagerInterface|null $storeManager
*/
public function __construct(
ConfigInterface $contactsConfig,
TransportBuilder $transportBuilder,
- StateInterface $inlineTranslation
+ StateInterface $inlineTranslation,
+ StoreManagerInterface $storeManager = null
) {
$this->contactsConfig = $contactsConfig;
$this->transportBuilder = $transportBuilder;
$this->inlineTranslation = $inlineTranslation;
+ $this->storeManager = $storeManager ?:
+ ObjectManager::getInstance()->get(StoreManagerInterface::class);
}
/**
@@ -58,8 +71,8 @@ public function send($replyTo, array $variables)
->setTemplateIdentifier($this->contactsConfig->emailTemplate())
->setTemplateOptions(
[
- 'area' => 'adminhtml',
- 'store' => \Magento\Store\Model\Store::DEFAULT_STORE_ID,
+ 'area' => 'frontend',
+ 'store' => $this->storeManager->getStore()->getId()
]
)
->setTemplateVars($variables)
diff --git a/app/code/Magento/Contact/Test/Unit/Model/MailTest.php b/app/code/Magento/Contact/Test/Unit/Model/MailTest.php
index e1e8fec435125..f432a4fc5ccee 100644
--- a/app/code/Magento/Contact/Test/Unit/Model/MailTest.php
+++ b/app/code/Magento/Contact/Test/Unit/Model/MailTest.php
@@ -8,6 +8,8 @@
use Magento\Contact\Model\ConfigInterface;
use Magento\Contact\Model\Mail;
+use Magento\Store\Model\StoreManagerInterface;
+use Magento\Store\Api\Data\StoreInterface;
class MailTest extends \PHPUnit_Framework_TestCase
{
@@ -32,6 +34,11 @@ class MailTest extends \PHPUnit_Framework_TestCase
*/
private $inlineTranslationMock;
+ /**
+ * @var \PHPUnit_Framework_MockObject_MockObject
+ */
+ private $storeManagerMock;
+
/**
* @var Mail
*/
@@ -50,10 +57,13 @@ protected function setUp()
)->disableOriginalConstructor(
)->getMock();
+ $this->storeManagerMock = $this->getMock(StoreManagerInterface::class);
+
$this->mail = new Mail(
$this->configMock,
$this->transportBuilderMock,
- $this->inlineTranslationMock
+ $this->inlineTranslationMock,
+ $this->storeManagerMock
);
}
@@ -64,6 +74,11 @@ public function testSendMail()
$transport = $this->getMock(\Magento\Framework\Mail\TransportInterface::class, [], [], '', false);
+ $store = $this->getMock(StoreInterface::class);
+ $store->expects($this->once())->method('getId')->willReturn(555);
+
+ $this->storeManagerMock->expects($this->once())->method('getStore')->willReturn($store);
+
$this->transportBuilderMock->expects($this->once())
->method('setTemplateIdentifier')
->will($this->returnSelf());
@@ -71,8 +86,8 @@ public function testSendMail()
$this->transportBuilderMock->expects($this->once())
->method('setTemplateOptions')
->with([
- 'area' => \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE,
- 'store' => \Magento\Store\Model\Store::DEFAULT_STORE_ID,
+ 'area' => 'frontend',
+ 'store' => 555,
])
->will($this->returnSelf());
diff --git a/app/code/Magento/Contact/etc/email_templates.xml b/app/code/Magento/Contact/etc/email_templates.xml
index 8ae3b643f43c8..8f3f5ee442f7d 100644
--- a/app/code/Magento/Contact/etc/email_templates.xml
+++ b/app/code/Magento/Contact/etc/email_templates.xml
@@ -6,5 +6,5 @@
*/
-->
-
+
diff --git a/app/code/Magento/Contact/view/adminhtml/email/submitted_form.html b/app/code/Magento/Contact/view/adminhtml/email/submitted_form.html
deleted file mode 100644
index f65d67e6cafc3..0000000000000
--- a/app/code/Magento/Contact/view/adminhtml/email/submitted_form.html
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
-
-{{trans "Name: %name" name=$data.name}}
-{{trans "Email: %email" email=$data.email}}
-{{trans "Phone Number: %telephone" telephone=$data.telephone}}
-
-{{trans "Comment: %comment" comment=$data.comment}}
diff --git a/app/code/Magento/Contact/view/frontend/email/submitted_form.html b/app/code/Magento/Contact/view/frontend/email/submitted_form.html
new file mode 100644
index 0000000000000..1bce6159c586a
--- /dev/null
+++ b/app/code/Magento/Contact/view/frontend/email/submitted_form.html
@@ -0,0 +1,34 @@
+
+
+
+
+{{template config_path="design/email/header_template"}}
+
+
+
+ {{trans "Name"}} |
+ {{var data.name}} |
+
+
+ {{trans "Email"}} |
+ {{var data.email}} |
+
+
+ {{trans "Phone"}} |
+ {{var data.telephone}} |
+
+
+{{trans "Message"}}
+{{var data.comment}}
+
+{{template config_path="design/email/footer_template"}}
diff --git a/app/code/Magento/Sitemap/Model/ResourceModel/Catalog/Product.php b/app/code/Magento/Sitemap/Model/ResourceModel/Catalog/Product.php
index d718c661fb2e8..eb0a1c2efbd5c 100644
--- a/app/code/Magento/Sitemap/Model/ResourceModel/Catalog/Product.php
+++ b/app/code/Magento/Sitemap/Model/ResourceModel/Catalog/Product.php
@@ -7,11 +7,11 @@
use Magento\CatalogUrlRewrite\Model\ProductUrlRewriteGenerator;
use Magento\Store\Model\Store;
+use Magento\Framework\App\ObjectManager;
/**
* Sitemap resource product collection model
*
- * @author Magento Core Team
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class Product extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
@@ -71,9 +71,20 @@ class Product extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
/**
* @var \Magento\Catalog\Model\Product\Media\Config
+ * @deprecated unused
*/
protected $_mediaConfig;
+ /**
+ * @var \Magento\Catalog\Model\Product
+ */
+ private $productModel;
+
+ /**
+ * @var \Magento\Catalog\Helper\Image
+ */
+ private $catalogImageHelper;
+
/**
* @param \Magento\Framework\Model\ResourceModel\Db\Context $context
* @param \Magento\Sitemap\Helper\Data $sitemapData
@@ -85,6 +96,8 @@ class Product extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
* @param \Magento\Catalog\Model\Product\Gallery\ReadHandler $mediaGalleryReadHandler
* @param \Magento\Catalog\Model\Product\Media\Config $mediaConfig
* @param string $connectionName
+ * @param \Magento\Catalog\Model\Product $productModel
+ * @param \Magento\Catalog\Helper\Image $catalogImageHelper
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function __construct(
@@ -97,7 +110,9 @@ public function __construct(
\Magento\Catalog\Model\ResourceModel\Product\Gallery $mediaGalleryResourceModel,
\Magento\Catalog\Model\Product\Gallery\ReadHandler $mediaGalleryReadHandler,
\Magento\Catalog\Model\Product\Media\Config $mediaConfig,
- $connectionName = null
+ $connectionName = null,
+ \Magento\Catalog\Model\Product $productModel = null,
+ \Magento\Catalog\Helper\Image $catalogImageHelper = null
) {
$this->_productResource = $productResource;
$this->_storeManager = $storeManager;
@@ -107,6 +122,9 @@ public function __construct(
$this->mediaGalleryReadHandler = $mediaGalleryReadHandler;
$this->_mediaConfig = $mediaConfig;
$this->_sitemapData = $sitemapData;
+ $this->productModel = $productModel ?: ObjectManager::getInstance()->get(\Magento\Catalog\Model\Product::class);
+ $this->catalogImageHelper = $catalogImageHelper ?: ObjectManager::getInstance()
+ ->get(\Magento\Catalog\Helper\Image::class);
parent::__construct($context, $connectionName);
}
@@ -339,7 +357,7 @@ protected function _loadProductImages($product, $storeId)
) {
$imagesCollection = [
new \Magento\Framework\DataObject(
- ['url' => $this->_getMediaConfig()->getBaseMediaUrlAddition() . $product->getImage()]
+ ['url' => $this->getProductImageUrl($product->getImage())]
),
];
}
@@ -348,7 +366,7 @@ protected function _loadProductImages($product, $storeId)
// Determine thumbnail path
$thumbnail = $product->getThumbnail();
if ($thumbnail && $product->getThumbnail() != self::NOT_SELECTED_IMAGE) {
- $thumbnail = $this->_getMediaConfig()->getBaseMediaUrlAddition() . $thumbnail;
+ $thumbnail = $this->getProductImageUrl($thumbnail);
} else {
$thumbnail = $imagesCollection[0]->getUrl();
}
@@ -378,11 +396,10 @@ protected function _getAllProductImages($product, $storeId)
$imagesCollection = [];
if ($gallery) {
- $productMediaPath = $this->_getMediaConfig()->getBaseMediaUrlAddition();
foreach ($gallery as $image) {
$imagesCollection[] = new \Magento\Framework\DataObject(
[
- 'url' => $productMediaPath . $image['file'],
+ 'url' => $this->getProductImageUrl($image['file']),
'caption' => $image['label'] ? $image['label'] : $image['label_default'],
]
);
@@ -396,9 +413,28 @@ protected function _getAllProductImages($product, $storeId)
* Get media config
*
* @return \Magento\Catalog\Model\Product\Media\Config
+ * @deprecated No longer used, as we're getting full image URL from getProductImageUrl method
+ * @see getProductImageUrl()
*/
protected function _getMediaConfig()
{
return $this->_mediaConfig;
}
+
+ /**
+ * Get product image URL from image filename and path
+ *
+ * @param string $image
+ * @return string
+ */
+ private function getProductImageUrl($image)
+ {
+ $productObject = $this->productModel;
+ $imgUrl = $this->catalogImageHelper
+ ->init($productObject, 'product_page_image_large')
+ ->setImageFile($image)
+ ->getUrl();
+
+ return $imgUrl;
+ }
}
diff --git a/app/code/Magento/Sitemap/Model/Sitemap.php b/app/code/Magento/Sitemap/Model/Sitemap.php
index 13a90cc627769..6abc13c98c35e 100644
--- a/app/code/Magento/Sitemap/Model/Sitemap.php
+++ b/app/code/Magento/Sitemap/Model/Sitemap.php
@@ -448,7 +448,7 @@ protected function _isSplitRequired($row)
* @param null|string $lastmod
* @param null|string $changefreq
* @param null|string $priority
- * @param null|array $images
+ * @param null|array|\Magento\Framework\DataObject $images
* @return string
* Sitemap images
* @see http://support.google.com/webmasters/bin/answer.py?hl=en&answer=178636
@@ -473,7 +473,7 @@ protected function _getSitemapRow($url, $lastmod = null, $changefreq = null, $pr
// Add Images to sitemap
foreach ($images->getCollection() as $image) {
$row .= '';
- $row .= '' . htmlspecialchars($this->_getMediaUrl($image->getUrl())) . '';
+ $row .= '' . htmlspecialchars($image->getUrl()) . '';
$row .= '' . htmlspecialchars($images->getTitle()) . '';
if ($image->getCaption()) {
$row .= '' . htmlspecialchars($image->getCaption()) . '';
@@ -483,9 +483,7 @@ protected function _getSitemapRow($url, $lastmod = null, $changefreq = null, $pr
// Add PageMap image for Google web search
$row .= '';
$row .= '';
- $row .= '';
+ $row .= '';
$row .= '';
}
@@ -591,6 +589,7 @@ protected function _getBaseDir()
*/
protected function _getStoreBaseUrl($type = \Magento\Framework\UrlInterface::URL_TYPE_LINK)
{
+ /** @var \Magento\Store\Model\Store $store */
$store = $this->_storeManager->getStore($this->getStoreId());
$isSecure = $store->isUrlSecure();
return rtrim($store->getBaseUrl($type, $isSecure), '/') . '/';
@@ -613,6 +612,8 @@ protected function _getUrl($url, $type = \Magento\Framework\UrlInterface::URL_TY
*
* @param string $url
* @return string
+ * @deprecated No longer used, as we're generating product image URLs inside collection instead
+ * @see \Magento\Sitemap\Model\ResourceModel\Catalog\Product::_loadProductImages()
*/
protected function _getMediaUrl($url)
{
diff --git a/app/code/Magento/Sitemap/Test/Unit/Model/SitemapTest.php b/app/code/Magento/Sitemap/Test/Unit/Model/SitemapTest.php
index 241e394187147..fb1379ecfca28 100644
--- a/app/code/Magento/Sitemap/Test/Unit/Model/SitemapTest.php
+++ b/app/code/Magento/Sitemap/Test/Unit/Model/SitemapTest.php
@@ -535,6 +535,8 @@ protected function _getModelMock($mockBeforeSave = false)
]
)
);
+
+ $storeBaseMediaUrl = 'http://store.com/pub/media/catalog/product/cache/c9e0b0ef589f3508e5ba515cde53c5ff/';
$this->_sitemapProductMock->expects(
$this->any()
)->method(
@@ -553,13 +555,16 @@ protected function _getModelMock($mockBeforeSave = false)
[
'collection' => [
new \Magento\Framework\DataObject(
- ['url' => 'image1.png', 'caption' => 'caption & > title < "']
+ [
+ 'url' => $storeBaseMediaUrl.'i/m/image1.png',
+ 'caption' => 'caption & > title < "'
+ ]
),
new \Magento\Framework\DataObject(
- ['url' => 'image_no_caption.png', 'caption' => null]
+ ['url' => $storeBaseMediaUrl.'i/m/image_no_caption.png', 'caption' => null]
),
],
- 'thumbnail' => 'thumbnail.jpg',
+ 'thumbnail' => $storeBaseMediaUrl.'t/h/thumbnail.jpg',
'title' => 'Product & > title < "',
]
),
diff --git a/app/code/Magento/Sitemap/Test/Unit/Model/_files/sitemap-1-4.xml b/app/code/Magento/Sitemap/Test/Unit/Model/_files/sitemap-1-4.xml
index e9fd2b00a909c..7111154efbf85 100644
--- a/app/code/Magento/Sitemap/Test/Unit/Model/_files/sitemap-1-4.xml
+++ b/app/code/Magento/Sitemap/Test/Unit/Model/_files/sitemap-1-4.xml
@@ -14,18 +14,18 @@
monthly
0.5
- http://store.com/image1.png
+ http://store.com/pub/media/catalog/product/cache/c9e0b0ef589f3508e5ba515cde53c5ff/i/m/image1.png
Product & > title < "
caption & > title < "
- http://store.com/image_no_caption.png
+ http://store.com/pub/media/catalog/product/cache/c9e0b0ef589f3508e5ba515cde53c5ff/i/m/image_no_caption.png
Product & > title < "
-
+
diff --git a/app/code/Magento/Sitemap/Test/Unit/Model/_files/sitemap-single.xml b/app/code/Magento/Sitemap/Test/Unit/Model/_files/sitemap-single.xml
index d4801a014aabc..e79e022c98995 100644
--- a/app/code/Magento/Sitemap/Test/Unit/Model/_files/sitemap-single.xml
+++ b/app/code/Magento/Sitemap/Test/Unit/Model/_files/sitemap-single.xml
@@ -32,18 +32,18 @@
monthly
0.5
- http://store.com/image1.png
+ http://store.com/pub/media/catalog/product/cache/c9e0b0ef589f3508e5ba515cde53c5ff/i/m/image1.png
Product & > title < "
caption & > title < "
- http://store.com/image_no_caption.png
+ http://store.com/pub/media/catalog/product/cache/c9e0b0ef589f3508e5ba515cde53c5ff/i/m/image_no_caption.png
Product & > title < "
-
+
diff --git a/app/design/frontend/Magento/blank/web/css/source/_email-base.less b/app/design/frontend/Magento/blank/web/css/source/_email-base.less
index 1cdae848ec318..1d7336b8b3222 100644
--- a/app/design/frontend/Magento/blank/web/css/source/_email-base.less
+++ b/app/design/frontend/Magento/blank/web/css/source/_email-base.less
@@ -287,3 +287,19 @@ body {
}
}
}
+
+.message-details {
+ margin-bottom: @indent__s;
+
+ b {
+ font-weight: bold;
+ }
+
+ td {
+ padding-bottom: @indent__xs;
+
+ b {
+ margin-right: @indent__s;
+ }
+ }
+}
diff --git a/dev/tests/integration/testsuite/Magento/Sitemap/Model/ResourceModel/Catalog/ProductTest.php b/dev/tests/integration/testsuite/Magento/Sitemap/Model/ResourceModel/Catalog/ProductTest.php
index 62b97e54bf0f0..e4ab0aa99fa44 100644
--- a/dev/tests/integration/testsuite/Magento/Sitemap/Model/ResourceModel/Catalog/ProductTest.php
+++ b/dev/tests/integration/testsuite/Magento/Sitemap/Model/ResourceModel/Catalog/ProductTest.php
@@ -14,6 +14,11 @@
*/
class ProductTest extends \PHPUnit_Framework_TestCase
{
+ /**
+ * Base product image path
+ */
+ const BASE_IMAGE_PATH = 'http://localhost/pub/media/catalog/product/cache/c9e0b0ef589f3508e5ba515cde53c5ff';
+
/**
* Test getCollection None images
* 1) Check that image attributes were not loaded
@@ -72,7 +77,7 @@ public function testGetCollectionAll()
$this->assertNotEmpty($products[4]->getImages(), 'Images were not loaded');
$this->assertEquals('Simple Images', $products[4]->getImages()->getTitle(), 'Incorrect title');
$this->assertEquals(
- 'catalog/product/m/a/magento_image_sitemap.png',
+ self::BASE_IMAGE_PATH.'/m/a/magento_image_sitemap.png',
$products[4]->getImages()->getThumbnail(),
'Incorrect thumbnail'
);
@@ -80,12 +85,12 @@ public function testGetCollectionAll()
$imagesCollection = $products[4]->getImages()->getCollection();
$this->assertEquals(
- 'catalog/product/m/a/magento_image_sitemap.png',
+ self::BASE_IMAGE_PATH.'/m/a/magento_image_sitemap.png',
$imagesCollection[0]->getUrl(),
'Incorrect image url'
);
$this->assertEquals(
- 'catalog/product/s/e/second_image.png',
+ self::BASE_IMAGE_PATH.'/s/e/second_image.png',
$imagesCollection[1]->getUrl(),
'Incorrect image url'
);
@@ -97,12 +102,12 @@ public function testGetCollectionAll()
$imagesCollection = $products[5]->getImages()->getCollection();
$this->assertCount(1, $imagesCollection);
$this->assertEquals(
- 'catalog/product/s/e/second_image_1.png',
+ self::BASE_IMAGE_PATH.'/s/e/second_image_1.png',
$imagesCollection[0]->getUrl(),
'Image url is incorrect'
);
$this->assertEquals(
- 'catalog/product/s/e/second_image_1.png',
+ self::BASE_IMAGE_PATH.'/s/e/second_image_1.png',
$products[5]->getImages()->getThumbnail(),
'Product thumbnail is incorrect'
);
@@ -140,7 +145,7 @@ public function testGetCollectionBase()
$this->assertNotEmpty($products[4]->getImages(), 'Images were not loaded');
$this->assertEquals('Simple Images', $products[4]->getImages()->getTitle(), 'Incorrect title');
$this->assertEquals(
- 'catalog/product/s/e/second_image.png',
+ self::BASE_IMAGE_PATH.'/s/e/second_image.png',
$products[4]->getImages()->getThumbnail(),
'Incorrect thumbnail'
);
@@ -148,7 +153,7 @@ public function testGetCollectionBase()
$imagesCollection = $products[4]->getImages()->getCollection();
$this->assertEquals(
- 'catalog/product/s/e/second_image.png',
+ self::BASE_IMAGE_PATH.'/s/e/second_image.png',
$imagesCollection[0]->getUrl(),
'Incorrect image url'
);