i am created custom module as per requirement.my details page add custom button when click then open popup and submit data. at time my data is save database and admin grid but email not send. i will share my code.
my product details page custom button click then open pop up afte form submit get error for below
TypeError: Illegal offset type in /var/www/html/magento247module/vendor/magento/framework/DataObject.php:132
#13 /var/www/html/magento247module/vendor/magento/framework/Interception/Interceptor.php(138): MymoduleVendornameControllerIndexSubmitInterceptor->___callParent()
i have not idea about this.so any one have solution then give me answer properly
<?php
namespace MymoduleVendornameControllerIndex;
use MagentoFrameworkAppActionContext;
use MagentoFrameworkViewResultPageFactory;
use MymoduleVendornameModelExtensionFactory;
use MagentoFrameworkControllerResultFactory;
use MagentoFrameworkAppActionAction;
use MagentoFrameworkAppFilesystemDirectoryList;
class Submit extends Action
{
/**
* Result Factory
*
* @var MagentoFrameworkViewResultPageFactory
*/
protected $resultPageFactory;
/**
* Inquery Factory
*
* @var MymoduleVendornameModelExtensionFactory
*/
protected $extensionFactory;
/**
* Helper
*
* @var MymoduleVendornameHelperData
*/
protected $helperData;
/**
* Config Value
*
* @var MagentoFrameworkAppConfigScopeConfigInterface
*/
protected $scopeConfig;
/**
* Storemanager Value
*
* @var \MagentoStoreModelStoreManagerInterface
*/
protected $storeManager;
/**
* Undocumented function
*
* @param Context $context
* @param PageFactory $resultPageFactory
* @param ExtensionFactory $extensionFactory
* @param MagentoFrameworkAppConfigScopeConfigInterface $scopeConfig
* @param MagentoStoreModelStoreManagerInterface $storeManager
* @param MymoduleVendornameHelperData $helperData
*/
public function __construct(
Context $context,
PageFactory $resultPageFactory,
ExtensionFactory $extensionFactory,
MagentoFrameworkAppConfigScopeConfigInterface $scopeConfig,
MagentoStoreModelStoreManagerInterface $storeManager,
MymoduleVendornameHelperData $helperData
) {
$this->resultPageFactory = $resultPageFactory;
$this->extensionFactory = $extensionFactory;
$this->scopeConfig = $scopeConfig;
$this->storeManager = $storeManager;
$this->helperData = $helperData;
parent::__construct($context);
}
/**
* Execute Function
*
* @return void
*/
public function execute()
{
$data = (array)$this->getRequest()->getPost();
try {
if ($data) {
$model = $this->extensionFactory->create();
$model->setData($data);
$model->save();
$this->helperData->sendCustomer($data);
$this->helperData->sendAdmin($data);
$sucessmessage = $this->scopeConfig->getValue(
"product_inquiry/general/success_msg",
MagentoStoreModelScopeInterface::SCOPE_STORE,
$this->storeManager->getStore()->getStoreId()
);
if ($sucessmessage) {
$this->messageManager->addSuccessMessage(
__($sucessmessage)
);
} else {
$this->messageManager->addSuccessMessage(
__("Thanks for being interested in our product. We will get back in touch with you soon!")
);
}
}
} catch (Exception $e) {
$this->messageManager->addErrorMessage(
$e,
__("We can't submit your request, Please try again.")
);
}
$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
$resultRedirect->setUrl($this->_redirect->getRefererUrl());
return $resultRedirect;
}
}