Rest magento中图像的基本URL应该是什么?
访问Rest API()以获取产品详细信息后,响应如下:Rest magento中图像的基本URL应该是什么?,rest,http,magento,magento2,Rest,Http,Magento,Magento2,访问Rest API()以获取产品详细信息后,响应如下: { "attribute_code": "image", "value": "/6/4/64275-152378-large.jpg" }, { "attribute_code": "small_image", "value": "/6/4/64275-152378-large.jpg" }, { "attribute_code": "th
{
"attribute_code": "image",
"value": "/6/4/64275-152378-large.jpg"
},
{
"attribute_code": "small_image",
"value": "/6/4/64275-152378-large.jpg"
},
{
"attribute_code": "thumbnail",
"value": "/6/4/64275-152378-large.jpg"
}
属性代码键中jpg的基本url应该是什么?无需修改API请求
/** @return string */
function getMediaBaseUrl() {
/** @var \Magento\Framework\ObjectManagerInterface $om */
$om = \Magento\Framework\App\ObjectManager::getInstance();
/** @var \Magento\Store\Model\StoreManagerInterface $storeManager */
$storeManager = $om->get('Magento\Store\Model\StoreManagerInterface');
/** @var \Magento\Store\Api\Data\StoreInterface|\Magento\Store\Model\Store $currentStore */
$currentStore = $storeManager->getStore();
return $currentStore->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA);
}
只需添加一个前缀:
因此,根据我的回答,新的URL将是:
前缀: