Error: Call to a member function getStoreId() on null in /Users/mac14/Sites/cleanlinesurf-upgrade/app/code/Fooman/PdfCustomiser/Block/AbstractSalesDocument.php:180
我在管理端的銷售>訂單中的操作下拉串列中列印發票時收到此錯誤。這是代碼:
$storeId = $this->getSalesObject()->getStoreId();
if ($storeId === null) {
$store = $this->_storeManager->getDefaultStoreView();
$storeId = $store->getId();
}
return $storeId;
uj5u.com熱心網友回復:
嘗試注射
Fooman_PdfCustomiser_Helper_Pdf $helper
然后使用
$helper->getStoreId()
uj5u.com熱心網友回復:
試試這個代碼:
protected $_storeManager;
public function __construct(
\Magento\Store\Model\StoreManagerInterface $storeManager
)
{
$this->_storeManager = $storeManager;
}
public function getStoreId()
{
return $this->_storeManager->getStore()->getId();
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/403047.html
標籤:
上一篇:我在C中的結構鏈表有問題
