skip to Main Content
Error: Call to a member function getStoreId() on null in /Users/mac14/Sites/cleanlinesurf-upgrade/app/code/Fooman/PdfCustomiser/Block/AbstractSalesDocument.php:180

I’m getting this error on print Invoice from Action dropdown in Sales>Orders on admin side. Here is the code:

$storeId = $this->getSalesObject()->getStoreId();
if ($storeId === null) {
   $store = $this->_storeManager->getDefaultStoreView();
   $storeId = $store->getId();
}
return $storeId;

2

Answers


  1. Try injecting

    Fooman_PdfCustomiser_Helper_Pdf $helper
    

    Then use

    $helper->getStoreId()
    
    Login or Signup to reply.
  2. Try this code:

    protected $_storeManager;    
    
        public function __construct(
            MagentoStoreModelStoreManagerInterface $storeManager
        )
        {        
            $this->_storeManager = $storeManager;
        }
        public function getStoreId()
        {
            return $this->_storeManager->getStore()->getId();
        }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search