I have created a module in which all the things is done just 2 things are remaining .
How to add Dynamic base url in Magento 2 theme JS file. ex : http://127.0.0.1/projectname how to get that dynamically.
How to pass success or error in JSON format using Module -> Model
it would be really helpful.
<?php namespace Namespcae\Modulename\Controller\Index; use Magento\Framework\View\Result\PageFactory; use Magento\Framework\App\Action\Context; class Test extends \Magento\Framework\App\Action\Action { protected $_configReader; protected $_pageFactory; protected $customer; public function __construct( \Magento\Framework\App\Action\Context $context, \Magento\Framework\App\DeploymentConfig\Reader $configReader, \Namespcae\Modulename\Model\Customer $customer, \Magento\Framework\View\Result\PageFactory $pageFactory) { $this->_pageFactory = $pageFactory; $this->_configReader = $configReader; $this->customer = $customer; return parent::__construct($context); } public function execute() { $productIds = [5]; /** Contains the id of the store in which you would like to enable/disable the product */ $storeId = 0; /** * You can put any number of product attributes here. However, in the scope of this code we are going to * only enable/disable the product. */ $attributes = [ 'status' => Status::STATUS_ENABLED ]; $this->productAction->updateAttributes($productIds, $attributes, $storeId); } } How can i send response success or error in JSON format.