0
<?php 
namespace Sdi\Orders\Helper;

use Sdi\Orders\Model\StubFactory;
use \Magento\Framework\Module\Dir\Reader; 
use Magento\Framework\View\Asset\Repository;
use Sdi\Orders\Model\EngravingFactory;
use \Magento\Checkout\Model\Cart;
use \Magento\Catalog\Model\Product;
use \Magento\Framework\Session\SessionManagerInterface;


class Data extends \Magento\Framework\App\Helper\AbstractHelper { 

    /** 
    * 
    @var \Magento\Framework\App\Config\ScopeConfigInterfac 
    */ 
    protected $_scopeConfig; 
    protected $_modelstubFactory;
    protected $_moduleReader;
    protected $_dir;
    protected $_customerSession;
    protected $_modelEngravingFactory;
    protected $_cart;
    protected $_product;
    protected $jsonHelper;
    protected $coresession;



    public function __construct( \Magento\Framework\App\Helper\Context $context,
        StubFactory $modelstubFactory,
        \Magento\Framework\Filesystem\DirectoryList $dir,
        \Magento\Customer\Model\Session $customerSession,
        EngravingFactory $modelEngravingFactory,
        Repository $assetRepo,
        Reader $moduleReader,
        Cart $cart,
        Product $product,
        SessionManagerInterface $coresession,
        \Magento\Framework\Json\Helper\Data $jsonHelper) {

       parent::__construct($context); 
       $this->_modelstubFactory = $modelstubFactory;
       $this->_dir = $dir;
       $this->_moduleReader = $moduleReader;
       $this->_customerSession = $customerSession;
       $this->_modelEngravingFactory = $modelEngravingFactory;
       $this->assetRepo = $assetRepo;
       $this->_cart = $cart;
       $this->_product = $product;
       $this->jsonHelper = $jsonHelper;
       $this->coresession = $coresession;

}


public function addEngraving($productId, $data) {

 $this->_customerSession->setData('engravings', $data);
}
private function hasMap($productId, $side) {
  return $engraving = $this->_customerSession->getData('engravings', array());
}
public function hasFrontMap($productId) {
    return $this->hasMap($productId, 'front');
}

I called the addEngraving() function and then i called the hasfrontmap() function in my custom phtml file its shows null value always, But i called the addEngraving() once i added getdata syntax in it, its shows the saved session value... whats wrong with my code..

Can't we set the session value in one function and accessing the same session variable in another function.

Please any one advice me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.