Commit 44e8568c by halweg

feat : order rest api 在最顶层添加图片url的第二种方法

parent 3182a8bb
......@@ -23,6 +23,10 @@ interface OrderItemInterface extends \Magento\Framework\Api\ExtensibleDataInterf
* Item ID.
*/
const ITEM_ID = 'item_id';
const IMAGE = 'image';
/*
* Order ID.
*/
......@@ -1824,4 +1828,9 @@ interface OrderItemInterface extends \Magento\Framework\Api\ExtensibleDataInterf
* @return $this
*/
public function setExtensionAttributes(\Magento\Sales\Api\Data\OrderItemExtensionInterface $extensionAttributes);
/**
* @return string|null
*/
public function getImage();
}
......@@ -2415,4 +2415,18 @@ class Item extends AbstractModel implements OrderItemInterface
{
return $this->getQtyToShip() > $this->getQtyToCancel();
}
/**
* @inheritdoc
*/
public function getImage() {
$product = $this->productRepository->get($this->getSku());
if ($product) {
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$storeManager = $objectManager->get('\Magento\Store\Model\StoreManagerInterface');
$hostname = $storeManager->getStore()->getBaseUrl();
return $hostname."media/catalog/product/".$product->getData('thumbnail');
}
return "null";
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment