Magento 2 : Invalid method MagentoEavModelEntityAttribute::isScopeStoreI created a custom module ,but getting...
I got the following comment from a reputed math journal. What does it mean?
In what cases must I use 了 and in what cases not?
Suggestions on how to spend Shaabath (constructively) alone
When did antialiasing start being available?
Can you move over difficult terrain with only 5 feet of movement?
Do native speakers use "ultima" and "proxima" frequently in spoken English?
Geography in 3D perspective
PTIJ What is the inyan of the Konami code in Uncle Moishy's song?
Why is indicated airspeed rather than ground speed used during the takeoff roll?
Relation between independence and correlation of uniform random variables
What (if any) is the reason to buy in small local stores?
How do hiring committees for research positions view getting "scooped"?
How to define limit operations in general topological spaces? Are nets able to do this?
Brake pads destroying wheels
How does 取材で訪れた integrate into this sentence?
Unfrosted light bulb
Describing a chess game in a novel
What is the significance behind "40 days" that often appears in the Bible?
Practical application of matrices and determinants
Can other pieces capture a threatening piece and prevent a checkmate?
PTIJ: Do Irish Jews have "the luck of the Irish"?
How to generate binary array whose elements with values 1 are randomly drawn
Help prove this basic trig identity please!
What does Jesus mean regarding "Raca," and "you fool?" - is he contrasting them?
Magento 2 : Invalid method MagentoEavModelEntityAttribute::isScopeStore
I created a custom module ,but getting error, not able to figure out what the error is about. How to get out of this error?Not able to add/update magento2 category post upgrade from 1.9 to 2.1.0How to override webapi.xml in custom module?Add configure product in Cart using Magento 2 API facing an issueMagento 2 Front controller reached 100 router match iterations issueMagento2 REST API get all customers detailsDeleted ShipperHQ module causing error in “All Customers” section of Magento 2Unable to Serialize Value Magento 2.2.6“Area code is not set” in var/logwhen click on place order then paypal showing error in Magento2
I am getting an issue on Magento 2.2.6 when trying to save my module record. This error occurs sometimes and the error disappears if run Magento upgrade command. But it comes again sometime.
system.log :
[2019-03-18 04:46:32] main.CRITICAL: Exception message: Invalid method MagentoEavModelEntityAttribute::isScopeStore
Trace: #0 /var/www/html/test/app/code/VendorName/ModuleName/Model/ResourceModel/EntityName.php(147): MagentoFrameworkDataObject->__call('isScopeStore', Array)
#1 /var/www/html/test/vendor/magento/module-eav/Model/Entity/AbstractEntity.php(1536): VendorNameModuleNameModelResourceModelEntityName->_saveAttribute(Object(VendorNameModuleNameModelEntityName), Object(MagentoEavModelEntityAttribute), '0')
#2 /var/www/html/test/vendor/magento/module-eav/Model/Entity/AbstractEntity.php(1496): MagentoEavModelEntityAbstractEntity->_insertAttribute(Object(VendorNameModuleNameModelEntityName), Object(MagentoEavModelEntityAttribute), '0')
#3 /var/www/html/test/vendor/magento/module-eav/Model/Entity/AbstractEntity.php(1227): MagentoEavModelEntityAbstractEntity->_processSaveData(Array)
#4 /var/www/html/test/vendor/magento/module-eav/Model/Entity/AbstractEntity.php(1198): MagentoEavModelEntityAbstractEntity->processSave(Object(VendorNameModuleNameModelEntityName))
#5 /var/www/html/test/vendor/magento/framework/Interception/Interceptor.php(58): MagentoEavModelEntityAbstractEntity->save(Object(VendorNameModuleNameModelEntityName))
#6 /var/www/html/test/vendor/magento/framework/Interception/Interceptor.php(138): VendorNameModuleNameModelResourceModelEntityNameInterceptor->___callParent('save', Array)
#7 /var/www/html/test/vendor/magento/framework/App/Cache/FlushCacheByTags.php(68): VendorNameModuleNameModelResourceModelEntityNameInterceptor->MagentoFrameworkInterception{closure}(Object(VendorNameModuleNameModelEntityName))
#8 /var/www/html/test/vendor/magento/framework/Interception/Interceptor.php(135): MagentoFrameworkAppCacheFlushCacheByTags->aroundSave(Object(VendorNameModuleNameModelResourceModelEntityNameInterceptor), Object(Closure), Object(VendorNameModuleNameModelEntityName))
#9 /var/www/html/test/vendor/magento/framework/Interception/Interceptor.php(153): VendorNameModuleNameModelResourceModelEntityNameInterceptor->MagentoFrameworkInterception{closure}(Object(VendorNameModuleNameModelEntityName))
#10 /var/www/html/test/generated/code/VendorName/ModuleName/Model/ResourceModel/EntityName/Interceptor.php(468): VendorNameModuleNameModelResourceModelEntityNameInterceptor->___callPlugins('save', Array, NULL)
#11 /var/www/html/test/vendor/magento/framework/Model/AbstractModel.php(647): VendorNameModuleNameModelResourceModelEntityNameInterceptor->save(Object(VendorNameModuleNameModelEntityName))
#12 /var/www/html/test/app/code/VendorName/ModuleName/Controller/Adminhtml/EntityName/Save.php(86): MagentoFrameworkModelAbstractModel->save()
#13 /var/www/html/test/generated/code/VendorName/ModuleName/Controller/Adminhtml/EntityName/Save/Interceptor.php(24): VendorNameModuleNameControllerAdminhtmlEntityNameSave->execute()
#14 /var/www/html/test/vendor/magento/framework/App/Action/Action.php(107): VendorNameModuleNameControllerAdminhtmlEntityNameSaveInterceptor->execute()
#15 /var/www/html/test/vendor/magento/module-backend/App/AbstractAction.php(235): MagentoFrameworkAppActionAction->dispatch(Object(MagentoFrameworkAppRequestHttp))
#16 /var/www/html/test/vendor/magento/framework/Interception/Interceptor.php(58): MagentoBackendAppAbstractAction->dispatch(Object(MagentoFrameworkAppRequestHttp))
#17 /var/www/html/test/vendor/magento/framework/Interception/Interceptor.php(138): VendorNameModuleNameControllerAdminhtmlEntityNameSaveInterceptor->___callParent('dispatch', Array)
#18 /var/www/html/test/vendor/magento/module-backend/App/Action/Plugin/Authentication.php(143): VendorNameModuleNameControllerAdminhtmlEntityNameSaveInterceptor->MagentoFrameworkInterception{closure}(Object(MagentoFrameworkAppRequestHttp))
#19 /var/www/html/test/vendor/magento/framework/Interception/Interceptor.php(135): MagentoBackendAppActionPluginAuthentication->aroundDispatch(Object(VendorNameModuleNameControllerAdminhtmlEntityNameSaveInterceptor), Object(Closure), Object(MagentoFrameworkAppRequestHttp))
#20 /var/www/html/test/vendor/magento/framework/Interception/Interceptor.php(153): VendorNameModuleNameControllerAdminhtmlEntityNameSaveInterceptor->MagentoFrameworkInterception{closure}(Object(MagentoFrameworkAppRequestHttp))
#21 /var/www/html/test/generated/code/VendorName/ModuleName/Controller/Adminhtml/EntityName/Save/Interceptor.php(39): VendorNameModuleNameControllerAdminhtmlEntityNameSaveInterceptor->___callPlugins('dispatch', Array, NULL)
#22 /var/www/html/test/vendor/magento/framework/App/FrontController.php(55): VendorNameModuleNameControllerAdminhtmlEntityNameSaveInterceptor->dispatch(Object(MagentoFrameworkAppRequestHttp))
#23 /var/www/html/test/vendor/magento/framework/Interception/Interceptor.php(58): MagentoFrameworkAppFrontController->dispatch(Object(MagentoFrameworkAppRequestHttp))
#24 /var/www/html/test/vendor/magento/framework/Interception/Interceptor.php(138): MagentoFrameworkAppFrontControllerInterceptor->___callParent('dispatch', Array)
#25 /var/www/html/test/vendor/magento/framework/Interception/Interceptor.php(153): MagentoFrameworkAppFrontControllerInterceptor->MagentoFrameworkInterception{closure}(Object(MagentoFrameworkAppRequestHttp))
#26 /var/www/html/test/generated/code/Magento/Framework/App/FrontController/Interceptor.php(26): MagentoFrameworkAppFrontControllerInterceptor->___callPlugins('dispatch', Array, Array)
#27 /var/www/html/test/vendor/magento/framework/App/Http.php(135): MagentoFrameworkAppFrontControllerInterceptor->dispatch(Object(MagentoFrameworkAppRequestHttp))
#28 /var/www/html/test/generated/code/Magento/Framework/App/Http/Interceptor.php(24): MagentoFrameworkAppHttp->launch()
#29 /var/www/html/test/vendor/magento/framework/App/Bootstrap.php(257): MagentoFrameworkAppHttpInterceptor->launch()
#30 /var/www/html/test/index.php(39): MagentoFrameworkAppBootstrap->run(Object(MagentoFrameworkAppHttpInterceptor))
#31 {main} [] []
[2019-03-18 04:47:03] main.CRITICAL: Exception message: Invalid method MagentoEavModelEntityAttribute::isScopeStore
Trace: #0 /var/www/html/test/app/code/VendorName/ModuleName/Model/ResourceModel/EntityName.php(147): MagentoFrameworkDataObject->__call('isScopeStore', Array)
#1 /var/www/html/test/vendor/magento/module-eav/Model/Entity/AbstractEntity.php(1536): VendorNameModuleNameModelResourceModelEntityName->_saveAttribute(Object(VendorNameModuleNameModelEntityName), Object(MagentoEavModelEntityAttribute), '0')
#2 /var/www/html/test/vendor/magento/module-eav/Model/Entity/AbstractEntity.php(1496): MagentoEavModelEntityAbstractEntity->_insertAttribute(Object(VendorNameModuleNameModelEntityName), Object(MagentoEavModelEntityAttribute), '0')
#3 /var/www/html/test/vendor/magento/module-eav/Model/Entity/AbstractEntity.php(1227): MagentoEavModelEntityAbstractEntity->_processSaveData(Array)
#4 /var/www/html/test/vendor/magento/module-eav/Model/Entity/AbstractEntity.php(1198): MagentoEavModelEntityAbstractEntity->processSave(Object(VendorNameModuleNameModelEntityName))
#5 /var/www/html/test/vendor/magento/framework/Interception/Interceptor.php(58): MagentoEavModelEntityAbstractEntity->save(Object(VendorNameModuleNameModelEntityName))
#6 /var/www/html/test/vendor/magento/framework/Interception/Interceptor.php(138): VendorNameModuleNameModelResourceModelEntityNameInterceptor->___callParent('save', Array)
#7 /var/www/html/test/vendor/magento/framework/App/Cache/FlushCacheByTags.php(68): VendorNameModuleNameModelResourceModelEntityNameInterceptor->MagentoFrameworkInterception{closure}(Object(VendorNameModuleNameModelEntityName))
#8 /var/www/html/test/vendor/magento/framework/Interception/Interceptor.php(135): MagentoFrameworkAppCacheFlushCacheByTags->aroundSave(Object(VendorNameModuleNameModelResourceModelEntityNameInterceptor), Object(Closure), Object(VendorNameModuleNameModelEntityName))
#9 /var/www/html/test/vendor/magento/framework/Interception/Interceptor.php(153): VendorNameModuleNameModelResourceModelEntityNameInterceptor->MagentoFrameworkInterception{closure}(Object(VendorNameModuleNameModelEntityName))
#10 /var/www/html/test/generated/code/VendorName/ModuleName/Model/ResourceModel/EntityName/Interceptor.php(468): VendorNameModuleNameModelResourceModelEntityNameInterceptor->___callPlugins('save', Array, NULL)
#11 /var/www/html/test/vendor/magento/framework/Model/AbstractModel.php(647): VendorNameModuleNameModelResourceModelEntityNameInterceptor->save(Object(VendorNameModuleNameModelEntityName))
#12 /var/www/html/test/app/code/VendorName/ModuleName/Controller/Adminhtml/EntityName/Save.php(86): MagentoFrameworkModelAbstractModel->save()
#13 /var/www/html/test/generated/code/VendorName/ModuleName/Controller/Adminhtml/EntityName/Save/Interceptor.php(24): VendorNameModuleNameControllerAdminhtmlEntityNameSave->execute()
#14 /var/www/html/test/vendor/magento/framework/App/Action/Action.php(107): VendorNameModuleNameControllerAdminhtmlEntityNameSaveInterceptor->execute()
#15 /var/www/html/test/vendor/magento/module-backend/App/AbstractAction.php(235): MagentoFrameworkAppActionAction->dispatch(Object(MagentoFrameworkAppRequestHttp))
#16 /var/www/html/test/vendor/magento/framework/Interception/Interceptor.php(58): MagentoBackendAppAbstractAction->dispatch(Object(MagentoFrameworkAppRequestHttp))
#17 /var/www/html/test/vendor/magento/framework/Interception/Interceptor.php(138): VendorNameModuleNameControllerAdminhtmlEntityNameSaveInterceptor->___callParent('dispatch', Array)
#18 /var/www/html/test/vendor/magento/module-backend/App/Action/Plugin/Authentication.php(143): VendorNameModuleNameControllerAdminhtmlEntityNameSaveInterceptor->MagentoFrameworkInterception{closure}(Object(MagentoFrameworkAppRequestHttp))
#19 /var/www/html/test/vendor/magento/framework/Interception/Interceptor.php(135): MagentoBackendAppActionPluginAuthentication->aroundDispatch(Object(VendorNameModuleNameControllerAdminhtmlEntityNameSaveInterceptor), Object(Closure), Object(MagentoFrameworkAppRequestHttp))
#20 /var/www/html/test/vendor/magento/framework/Interception/Interceptor.php(153): VendorNameModuleNameControllerAdminhtmlEntityNameSaveInterceptor->MagentoFrameworkInterception{closure}(Object(MagentoFrameworkAppRequestHttp))
#21 /var/www/html/test/generated/code/VendorName/ModuleName/Controller/Adminhtml/EntityName/Save/Interceptor.php(39): VendorNameModuleNameControllerAdminhtmlEntityNameSaveInterceptor->___callPlugins('dispatch', Array, NULL)
#22 /var/www/html/test/vendor/magento/framework/App/FrontController.php(55): VendorNameModuleNameControllerAdminhtmlEntityNameSaveInterceptor->dispatch(Object(MagentoFrameworkAppRequestHttp))
#23 /var/www/html/test/vendor/magento/framework/Interception/Interceptor.php(58): MagentoFrameworkAppFrontController->dispatch(Object(MagentoFrameworkAppRequestHttp))
#24 /var/www/html/test/vendor/magento/framework/Interception/Interceptor.php(138): MagentoFrameworkAppFrontControllerInterceptor->___callParent('dispatch', Array)
#25 /var/www/html/test/vendor/magento/framework/Interception/Interceptor.php(153): MagentoFrameworkAppFrontControllerInterceptor->MagentoFrameworkInterception{closure}(Object(MagentoFrameworkAppRequestHttp))
#26 /var/www/html/test/generated/code/Magento/Framework/App/FrontController/Interceptor.php(26): MagentoFrameworkAppFrontControllerInterceptor->___callPlugins('dispatch', Array, Array)
#27 /var/www/html/test/vendor/magento/framework/App/Http.php(135): MagentoFrameworkAppFrontControllerInterceptor->dispatch(Object(MagentoFrameworkAppRequestHttp))
#28 /var/www/html/test/generated/code/Magento/Framework/App/Http/Interceptor.php(24): MagentoFrameworkAppHttp->launch()
#29 /var/www/html/test/vendor/magento/framework/App/Bootstrap.php(257): MagentoFrameworkAppHttpInterceptor->launch()
#30 /var/www/html/test/index.php(39): MagentoFrameworkAppBootstrap->run(Object(MagentoFrameworkAppHttpInterceptor))
#31 {main} [] []
/app/code/VendorName/ModuleName/Model/ResourceModel/EntityName.php
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace VendorNameModuleNameModelResourceModel;
use MagentoEavModelEntityAbstractEntity;
use MagentoEavModelEntityContext;
use MagentoFrameworkDataObject;
use MagentoStoreModelStore;
use MagentoStoreModelStoreManagerInterface;
use VendorNameModuleNameSetupEntitySetup;
class EntityName extends AbstractEntity {
/**
* Store id
*
* @var int
*/
protected $_storeId = null;
/**
* @var StoreManagerInterface
*/
protected $_storeManager;
/**
* @var EntityManager
*/
protected $entityManager;
/**
* [__construct description]
* @param Context $context [description]
* @param StoreManagerInterface $storeManager [description]
* @param array $data [description]
*/
public function __construct(
Context $context,
StoreManagerInterface $storeManager,
array $data = []
) {
parent::__construct($context, $data);
$this->setType(EntitySetup::ENTITY_TYPE_CODE);
$this->setConnection(EntitySetup::ENTITY_TYPE_CODE . '_read', EntitySetup::ENTITY_TYPE_CODE . '_write');
$this->_storeManager = $storeManager;
}
/**
* Set attribute set id and entity type id value
*
* @param MagentoFrameworkDataObject $customer
* @return $this
* @throws MagentoFrameworkExceptionLocalizedException
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
protected function _beforeSave(MagentoFrameworkDataObject $object) {
$object->setAttributeSetId($object->getAttributeSetId() ?: $this->getEntityType()->getDefaultAttributeSetId());
$object->setEntityTypeId($object->getEntityTypeId() ?: $this->getEntityType()->getEntityTypeId());
return parent::_beforeSave($object);
}
/**
* Return Entity Type instance
*
* @return MagentoEavModelEntityType
*/
public function getEntityType() {
if (empty($this->_type)) {
$this->setType(EntitySetup::ENTITY_TYPE_CODE);
}
return parent::getEntityType();
}
/**
* Retrieve ProductFaqNew entity default attributes
*
* @return string[]
*/
protected function _getDefaultAttributes() {
return [
'attribute_set_id',
'entity_type_id',
'created_at',
'updated_at',
];
}
/**
* Set store Id
*
* @param integer $storeId
* @return $this
*/
public function setStoreId($storeId) {
$this->_storeId = $storeId;
return $this;
}
/**
* Return store id
*
* @return integer
*/
public function getStoreId() {
if ($this->_storeId === null) {
return $this->_storeManager->getStore()->getId();
}
return $this->_storeId;
}
/**
* Set Attribute values to be saved
*
* @param MagentoFrameworkModelAbstractModel $object
* @param MagentoEavModelEntityAttributeAbstractAttribute $attribute
* @param mixed $value
* @return $this
*/
protected function _saveAttribute($object, $attribute, $value) {
$table = $attribute->getBackend()->getTable();
if (!isset($this->_attributeValuesToSave[$table])) {
$this->_attributeValuesToSave[$table] = [];
}
$entityIdField = $attribute->getBackend()->getEntityIdField();
$storeId = $object->getStoreId() ?: Store::DEFAULT_STORE_ID;
$data = [
$entityIdField => $object->getId(),
'entity_type_id' => $object->getEntityTypeId(),
'attribute_id' => $attribute->getId(),
'value' => $this->_prepareValueForSave($value, $attribute),
'store_id' => $storeId,
];
if (!$this->getEntityTable() || $this->getEntityTable() == MagentoEavModelEntity::DEFAULT_ENTITY_TABLE) {
$data['entity_type_id'] = $object->getEntityTypeId();
}
if ($attribute->isScopeStore()) {
/**
* Update attribute value for store
*/
$this->_attributeValuesToSave[$table][] = $data;
} elseif ($attribute->isScopeWebsite() && $storeId != Store::DEFAULT_STORE_ID) {
/**
* Update attribute value for website
*/
$storeIds = $this->_storeManager->getStore($storeId)->getWebsite()->getStoreIds(true);
foreach ($storeIds as $storeId) {
$data['store_id'] = (int) $storeId;
$this->_attributeValuesToSave[$table][] = $data;
}
} else {
/**
* Update global attribute value
*/
$data['store_id'] = Store::DEFAULT_STORE_ID;
$this->_attributeValuesToSave[$table][] = $data;
}
return $this;
}
}
what should I need to change?
Any help would be appriciated.
Thanks.
magento2 eav entity-manager
add a comment |
I am getting an issue on Magento 2.2.6 when trying to save my module record. This error occurs sometimes and the error disappears if run Magento upgrade command. But it comes again sometime.
system.log :
[2019-03-18 04:46:32] main.CRITICAL: Exception message: Invalid method MagentoEavModelEntityAttribute::isScopeStore
Trace: #0 /var/www/html/test/app/code/VendorName/ModuleName/Model/ResourceModel/EntityName.php(147): MagentoFrameworkDataObject->__call('isScopeStore', Array)
#1 /var/www/html/test/vendor/magento/module-eav/Model/Entity/AbstractEntity.php(1536): VendorNameModuleNameModelResourceModelEntityName->_saveAttribute(Object(VendorNameModuleNameModelEntityName), Object(MagentoEavModelEntityAttribute), '0')
#2 /var/www/html/test/vendor/magento/module-eav/Model/Entity/AbstractEntity.php(1496): MagentoEavModelEntityAbstractEntity->_insertAttribute(Object(VendorNameModuleNameModelEntityName), Object(MagentoEavModelEntityAttribute), '0')
#3 /var/www/html/test/vendor/magento/module-eav/Model/Entity/AbstractEntity.php(1227): MagentoEavModelEntityAbstractEntity->_processSaveData(Array)
#4 /var/www/html/test/vendor/magento/module-eav/Model/Entity/AbstractEntity.php(1198): MagentoEavModelEntityAbstractEntity->processSave(Object(VendorNameModuleNameModelEntityName))
#5 /var/www/html/test/vendor/magento/framework/Interception/Interceptor.php(58): MagentoEavModelEntityAbstractEntity->save(Object(VendorNameModuleNameModelEntityName))
#6 /var/www/html/test/vendor/magento/framework/Interception/Interceptor.php(138): VendorNameModuleNameModelResourceModelEntityNameInterceptor->___callParent('save', Array)
#7 /var/www/html/test/vendor/magento/framework/App/Cache/FlushCacheByTags.php(68): VendorNameModuleNameModelResourceModelEntityNameInterceptor->MagentoFrameworkInterception{closure}(Object(VendorNameModuleNameModelEntityName))
#8 /var/www/html/test/vendor/magento/framework/Interception/Interceptor.php(135): MagentoFrameworkAppCacheFlushCacheByTags->aroundSave(Object(VendorNameModuleNameModelResourceModelEntityNameInterceptor), Object(Closure), Object(VendorNameModuleNameModelEntityName))
#9 /var/www/html/test/vendor/magento/framework/Interception/Interceptor.php(153): VendorNameModuleNameModelResourceModelEntityNameInterceptor->MagentoFrameworkInterception{closure}(Object(VendorNameModuleNameModelEntityName))
#10 /var/www/html/test/generated/code/VendorName/ModuleName/Model/ResourceModel/EntityName/Interceptor.php(468): VendorNameModuleNameModelResourceModelEntityNameInterceptor->___callPlugins('save', Array, NULL)
#11 /var/www/html/test/vendor/magento/framework/Model/AbstractModel.php(647): VendorNameModuleNameModelResourceModelEntityNameInterceptor->save(Object(VendorNameModuleNameModelEntityName))
#12 /var/www/html/test/app/code/VendorName/ModuleName/Controller/Adminhtml/EntityName/Save.php(86): MagentoFrameworkModelAbstractModel->save()
#13 /var/www/html/test/generated/code/VendorName/ModuleName/Controller/Adminhtml/EntityName/Save/Interceptor.php(24): VendorNameModuleNameControllerAdminhtmlEntityNameSave->execute()
#14 /var/www/html/test/vendor/magento/framework/App/Action/Action.php(107): VendorNameModuleNameControllerAdminhtmlEntityNameSaveInterceptor->execute()
#15 /var/www/html/test/vendor/magento/module-backend/App/AbstractAction.php(235): MagentoFrameworkAppActionAction->dispatch(Object(MagentoFrameworkAppRequestHttp))
#16 /var/www/html/test/vendor/magento/framework/Interception/Interceptor.php(58): MagentoBackendAppAbstractAction->dispatch(Object(MagentoFrameworkAppRequestHttp))
#17 /var/www/html/test/vendor/magento/framework/Interception/Interceptor.php(138): VendorNameModuleNameControllerAdminhtmlEntityNameSaveInterceptor->___callParent('dispatch', Array)
#18 /var/www/html/test/vendor/magento/module-backend/App/Action/Plugin/Authentication.php(143): VendorNameModuleNameControllerAdminhtmlEntityNameSaveInterceptor->MagentoFrameworkInterception{closure}(Object(MagentoFrameworkAppRequestHttp))
#19 /var/www/html/test/vendor/magento/framework/Interception/Interceptor.php(135): MagentoBackendAppActionPluginAuthentication->aroundDispatch(Object(VendorNameModuleNameControllerAdminhtmlEntityNameSaveInterceptor), Object(Closure), Object(MagentoFrameworkAppRequestHttp))
#20 /var/www/html/test/vendor/magento/framework/Interception/Interceptor.php(153): VendorNameModuleNameControllerAdminhtmlEntityNameSaveInterceptor->MagentoFrameworkInterception{closure}(Object(MagentoFrameworkAppRequestHttp))
#21 /var/www/html/test/generated/code/VendorName/ModuleName/Controller/Adminhtml/EntityName/Save/Interceptor.php(39): VendorNameModuleNameControllerAdminhtmlEntityNameSaveInterceptor->___callPlugins('dispatch', Array, NULL)
#22 /var/www/html/test/vendor/magento/framework/App/FrontController.php(55): VendorNameModuleNameControllerAdminhtmlEntityNameSaveInterceptor->dispatch(Object(MagentoFrameworkAppRequestHttp))
#23 /var/www/html/test/vendor/magento/framework/Interception/Interceptor.php(58): MagentoFrameworkAppFrontController->dispatch(Object(MagentoFrameworkAppRequestHttp))
#24 /var/www/html/test/vendor/magento/framework/Interception/Interceptor.php(138): MagentoFrameworkAppFrontControllerInterceptor->___callParent('dispatch', Array)
#25 /var/www/html/test/vendor/magento/framework/Interception/Interceptor.php(153): MagentoFrameworkAppFrontControllerInterceptor->MagentoFrameworkInterception{closure}(Object(MagentoFrameworkAppRequestHttp))
#26 /var/www/html/test/generated/code/Magento/Framework/App/FrontController/Interceptor.php(26): MagentoFrameworkAppFrontControllerInterceptor->___callPlugins('dispatch', Array, Array)
#27 /var/www/html/test/vendor/magento/framework/App/Http.php(135): MagentoFrameworkAppFrontControllerInterceptor->dispatch(Object(MagentoFrameworkAppRequestHttp))
#28 /var/www/html/test/generated/code/Magento/Framework/App/Http/Interceptor.php(24): MagentoFrameworkAppHttp->launch()
#29 /var/www/html/test/vendor/magento/framework/App/Bootstrap.php(257): MagentoFrameworkAppHttpInterceptor->launch()
#30 /var/www/html/test/index.php(39): MagentoFrameworkAppBootstrap->run(Object(MagentoFrameworkAppHttpInterceptor))
#31 {main} [] []
[2019-03-18 04:47:03] main.CRITICAL: Exception message: Invalid method MagentoEavModelEntityAttribute::isScopeStore
Trace: #0 /var/www/html/test/app/code/VendorName/ModuleName/Model/ResourceModel/EntityName.php(147): MagentoFrameworkDataObject->__call('isScopeStore', Array)
#1 /var/www/html/test/vendor/magento/module-eav/Model/Entity/AbstractEntity.php(1536): VendorNameModuleNameModelResourceModelEntityName->_saveAttribute(Object(VendorNameModuleNameModelEntityName), Object(MagentoEavModelEntityAttribute), '0')
#2 /var/www/html/test/vendor/magento/module-eav/Model/Entity/AbstractEntity.php(1496): MagentoEavModelEntityAbstractEntity->_insertAttribute(Object(VendorNameModuleNameModelEntityName), Object(MagentoEavModelEntityAttribute), '0')
#3 /var/www/html/test/vendor/magento/module-eav/Model/Entity/AbstractEntity.php(1227): MagentoEavModelEntityAbstractEntity->_processSaveData(Array)
#4 /var/www/html/test/vendor/magento/module-eav/Model/Entity/AbstractEntity.php(1198): MagentoEavModelEntityAbstractEntity->processSave(Object(VendorNameModuleNameModelEntityName))
#5 /var/www/html/test/vendor/magento/framework/Interception/Interceptor.php(58): MagentoEavModelEntityAbstractEntity->save(Object(VendorNameModuleNameModelEntityName))
#6 /var/www/html/test/vendor/magento/framework/Interception/Interceptor.php(138): VendorNameModuleNameModelResourceModelEntityNameInterceptor->___callParent('save', Array)
#7 /var/www/html/test/vendor/magento/framework/App/Cache/FlushCacheByTags.php(68): VendorNameModuleNameModelResourceModelEntityNameInterceptor->MagentoFrameworkInterception{closure}(Object(VendorNameModuleNameModelEntityName))
#8 /var/www/html/test/vendor/magento/framework/Interception/Interceptor.php(135): MagentoFrameworkAppCacheFlushCacheByTags->aroundSave(Object(VendorNameModuleNameModelResourceModelEntityNameInterceptor), Object(Closure), Object(VendorNameModuleNameModelEntityName))
#9 /var/www/html/test/vendor/magento/framework/Interception/Interceptor.php(153): VendorNameModuleNameModelResourceModelEntityNameInterceptor->MagentoFrameworkInterception{closure}(Object(VendorNameModuleNameModelEntityName))
#10 /var/www/html/test/generated/code/VendorName/ModuleName/Model/ResourceModel/EntityName/Interceptor.php(468): VendorNameModuleNameModelResourceModelEntityNameInterceptor->___callPlugins('save', Array, NULL)
#11 /var/www/html/test/vendor/magento/framework/Model/AbstractModel.php(647): VendorNameModuleNameModelResourceModelEntityNameInterceptor->save(Object(VendorNameModuleNameModelEntityName))
#12 /var/www/html/test/app/code/VendorName/ModuleName/Controller/Adminhtml/EntityName/Save.php(86): MagentoFrameworkModelAbstractModel->save()
#13 /var/www/html/test/generated/code/VendorName/ModuleName/Controller/Adminhtml/EntityName/Save/Interceptor.php(24): VendorNameModuleNameControllerAdminhtmlEntityNameSave->execute()
#14 /var/www/html/test/vendor/magento/framework/App/Action/Action.php(107): VendorNameModuleNameControllerAdminhtmlEntityNameSaveInterceptor->execute()
#15 /var/www/html/test/vendor/magento/module-backend/App/AbstractAction.php(235): MagentoFrameworkAppActionAction->dispatch(Object(MagentoFrameworkAppRequestHttp))
#16 /var/www/html/test/vendor/magento/framework/Interception/Interceptor.php(58): MagentoBackendAppAbstractAction->dispatch(Object(MagentoFrameworkAppRequestHttp))
#17 /var/www/html/test/vendor/magento/framework/Interception/Interceptor.php(138): VendorNameModuleNameControllerAdminhtmlEntityNameSaveInterceptor->___callParent('dispatch', Array)
#18 /var/www/html/test/vendor/magento/module-backend/App/Action/Plugin/Authentication.php(143): VendorNameModuleNameControllerAdminhtmlEntityNameSaveInterceptor->MagentoFrameworkInterception{closure}(Object(MagentoFrameworkAppRequestHttp))
#19 /var/www/html/test/vendor/magento/framework/Interception/Interceptor.php(135): MagentoBackendAppActionPluginAuthentication->aroundDispatch(Object(VendorNameModuleNameControllerAdminhtmlEntityNameSaveInterceptor), Object(Closure), Object(MagentoFrameworkAppRequestHttp))
#20 /var/www/html/test/vendor/magento/framework/Interception/Interceptor.php(153): VendorNameModuleNameControllerAdminhtmlEntityNameSaveInterceptor->MagentoFrameworkInterception{closure}(Object(MagentoFrameworkAppRequestHttp))
#21 /var/www/html/test/generated/code/VendorName/ModuleName/Controller/Adminhtml/EntityName/Save/Interceptor.php(39): VendorNameModuleNameControllerAdminhtmlEntityNameSaveInterceptor->___callPlugins('dispatch', Array, NULL)
#22 /var/www/html/test/vendor/magento/framework/App/FrontController.php(55): VendorNameModuleNameControllerAdminhtmlEntityNameSaveInterceptor->dispatch(Object(MagentoFrameworkAppRequestHttp))
#23 /var/www/html/test/vendor/magento/framework/Interception/Interceptor.php(58): MagentoFrameworkAppFrontController->dispatch(Object(MagentoFrameworkAppRequestHttp))
#24 /var/www/html/test/vendor/magento/framework/Interception/Interceptor.php(138): MagentoFrameworkAppFrontControllerInterceptor->___callParent('dispatch', Array)
#25 /var/www/html/test/vendor/magento/framework/Interception/Interceptor.php(153): MagentoFrameworkAppFrontControllerInterceptor->MagentoFrameworkInterception{closure}(Object(MagentoFrameworkAppRequestHttp))
#26 /var/www/html/test/generated/code/Magento/Framework/App/FrontController/Interceptor.php(26): MagentoFrameworkAppFrontControllerInterceptor->___callPlugins('dispatch', Array, Array)
#27 /var/www/html/test/vendor/magento/framework/App/Http.php(135): MagentoFrameworkAppFrontControllerInterceptor->dispatch(Object(MagentoFrameworkAppRequestHttp))
#28 /var/www/html/test/generated/code/Magento/Framework/App/Http/Interceptor.php(24): MagentoFrameworkAppHttp->launch()
#29 /var/www/html/test/vendor/magento/framework/App/Bootstrap.php(257): MagentoFrameworkAppHttpInterceptor->launch()
#30 /var/www/html/test/index.php(39): MagentoFrameworkAppBootstrap->run(Object(MagentoFrameworkAppHttpInterceptor))
#31 {main} [] []
/app/code/VendorName/ModuleName/Model/ResourceModel/EntityName.php
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace VendorNameModuleNameModelResourceModel;
use MagentoEavModelEntityAbstractEntity;
use MagentoEavModelEntityContext;
use MagentoFrameworkDataObject;
use MagentoStoreModelStore;
use MagentoStoreModelStoreManagerInterface;
use VendorNameModuleNameSetupEntitySetup;
class EntityName extends AbstractEntity {
/**
* Store id
*
* @var int
*/
protected $_storeId = null;
/**
* @var StoreManagerInterface
*/
protected $_storeManager;
/**
* @var EntityManager
*/
protected $entityManager;
/**
* [__construct description]
* @param Context $context [description]
* @param StoreManagerInterface $storeManager [description]
* @param array $data [description]
*/
public function __construct(
Context $context,
StoreManagerInterface $storeManager,
array $data = []
) {
parent::__construct($context, $data);
$this->setType(EntitySetup::ENTITY_TYPE_CODE);
$this->setConnection(EntitySetup::ENTITY_TYPE_CODE . '_read', EntitySetup::ENTITY_TYPE_CODE . '_write');
$this->_storeManager = $storeManager;
}
/**
* Set attribute set id and entity type id value
*
* @param MagentoFrameworkDataObject $customer
* @return $this
* @throws MagentoFrameworkExceptionLocalizedException
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
protected function _beforeSave(MagentoFrameworkDataObject $object) {
$object->setAttributeSetId($object->getAttributeSetId() ?: $this->getEntityType()->getDefaultAttributeSetId());
$object->setEntityTypeId($object->getEntityTypeId() ?: $this->getEntityType()->getEntityTypeId());
return parent::_beforeSave($object);
}
/**
* Return Entity Type instance
*
* @return MagentoEavModelEntityType
*/
public function getEntityType() {
if (empty($this->_type)) {
$this->setType(EntitySetup::ENTITY_TYPE_CODE);
}
return parent::getEntityType();
}
/**
* Retrieve ProductFaqNew entity default attributes
*
* @return string[]
*/
protected function _getDefaultAttributes() {
return [
'attribute_set_id',
'entity_type_id',
'created_at',
'updated_at',
];
}
/**
* Set store Id
*
* @param integer $storeId
* @return $this
*/
public function setStoreId($storeId) {
$this->_storeId = $storeId;
return $this;
}
/**
* Return store id
*
* @return integer
*/
public function getStoreId() {
if ($this->_storeId === null) {
return $this->_storeManager->getStore()->getId();
}
return $this->_storeId;
}
/**
* Set Attribute values to be saved
*
* @param MagentoFrameworkModelAbstractModel $object
* @param MagentoEavModelEntityAttributeAbstractAttribute $attribute
* @param mixed $value
* @return $this
*/
protected function _saveAttribute($object, $attribute, $value) {
$table = $attribute->getBackend()->getTable();
if (!isset($this->_attributeValuesToSave[$table])) {
$this->_attributeValuesToSave[$table] = [];
}
$entityIdField = $attribute->getBackend()->getEntityIdField();
$storeId = $object->getStoreId() ?: Store::DEFAULT_STORE_ID;
$data = [
$entityIdField => $object->getId(),
'entity_type_id' => $object->getEntityTypeId(),
'attribute_id' => $attribute->getId(),
'value' => $this->_prepareValueForSave($value, $attribute),
'store_id' => $storeId,
];
if (!$this->getEntityTable() || $this->getEntityTable() == MagentoEavModelEntity::DEFAULT_ENTITY_TABLE) {
$data['entity_type_id'] = $object->getEntityTypeId();
}
if ($attribute->isScopeStore()) {
/**
* Update attribute value for store
*/
$this->_attributeValuesToSave[$table][] = $data;
} elseif ($attribute->isScopeWebsite() && $storeId != Store::DEFAULT_STORE_ID) {
/**
* Update attribute value for website
*/
$storeIds = $this->_storeManager->getStore($storeId)->getWebsite()->getStoreIds(true);
foreach ($storeIds as $storeId) {
$data['store_id'] = (int) $storeId;
$this->_attributeValuesToSave[$table][] = $data;
}
} else {
/**
* Update global attribute value
*/
$data['store_id'] = Store::DEFAULT_STORE_ID;
$this->_attributeValuesToSave[$table][] = $data;
}
return $this;
}
}
what should I need to change?
Any help would be appriciated.
Thanks.
magento2 eav entity-manager
add a comment |
I am getting an issue on Magento 2.2.6 when trying to save my module record. This error occurs sometimes and the error disappears if run Magento upgrade command. But it comes again sometime.
system.log :
[2019-03-18 04:46:32] main.CRITICAL: Exception message: Invalid method MagentoEavModelEntityAttribute::isScopeStore
Trace: #0 /var/www/html/test/app/code/VendorName/ModuleName/Model/ResourceModel/EntityName.php(147): MagentoFrameworkDataObject->__call('isScopeStore', Array)
#1 /var/www/html/test/vendor/magento/module-eav/Model/Entity/AbstractEntity.php(1536): VendorNameModuleNameModelResourceModelEntityName->_saveAttribute(Object(VendorNameModuleNameModelEntityName), Object(MagentoEavModelEntityAttribute), '0')
#2 /var/www/html/test/vendor/magento/module-eav/Model/Entity/AbstractEntity.php(1496): MagentoEavModelEntityAbstractEntity->_insertAttribute(Object(VendorNameModuleNameModelEntityName), Object(MagentoEavModelEntityAttribute), '0')
#3 /var/www/html/test/vendor/magento/module-eav/Model/Entity/AbstractEntity.php(1227): MagentoEavModelEntityAbstractEntity->_processSaveData(Array)
#4 /var/www/html/test/vendor/magento/module-eav/Model/Entity/AbstractEntity.php(1198): MagentoEavModelEntityAbstractEntity->processSave(Object(VendorNameModuleNameModelEntityName))
#5 /var/www/html/test/vendor/magento/framework/Interception/Interceptor.php(58): MagentoEavModelEntityAbstractEntity->save(Object(VendorNameModuleNameModelEntityName))
#6 /var/www/html/test/vendor/magento/framework/Interception/Interceptor.php(138): VendorNameModuleNameModelResourceModelEntityNameInterceptor->___callParent('save', Array)
#7 /var/www/html/test/vendor/magento/framework/App/Cache/FlushCacheByTags.php(68): VendorNameModuleNameModelResourceModelEntityNameInterceptor->MagentoFrameworkInterception{closure}(Object(VendorNameModuleNameModelEntityName))
#8 /var/www/html/test/vendor/magento/framework/Interception/Interceptor.php(135): MagentoFrameworkAppCacheFlushCacheByTags->aroundSave(Object(VendorNameModuleNameModelResourceModelEntityNameInterceptor), Object(Closure), Object(VendorNameModuleNameModelEntityName))
#9 /var/www/html/test/vendor/magento/framework/Interception/Interceptor.php(153): VendorNameModuleNameModelResourceModelEntityNameInterceptor->MagentoFrameworkInterception{closure}(Object(VendorNameModuleNameModelEntityName))
#10 /var/www/html/test/generated/code/VendorName/ModuleName/Model/ResourceModel/EntityName/Interceptor.php(468): VendorNameModuleNameModelResourceModelEntityNameInterceptor->___callPlugins('save', Array, NULL)
#11 /var/www/html/test/vendor/magento/framework/Model/AbstractModel.php(647): VendorNameModuleNameModelResourceModelEntityNameInterceptor->save(Object(VendorNameModuleNameModelEntityName))
#12 /var/www/html/test/app/code/VendorName/ModuleName/Controller/Adminhtml/EntityName/Save.php(86): MagentoFrameworkModelAbstractModel->save()
#13 /var/www/html/test/generated/code/VendorName/ModuleName/Controller/Adminhtml/EntityName/Save/Interceptor.php(24): VendorNameModuleNameControllerAdminhtmlEntityNameSave->execute()
#14 /var/www/html/test/vendor/magento/framework/App/Action/Action.php(107): VendorNameModuleNameControllerAdminhtmlEntityNameSaveInterceptor->execute()
#15 /var/www/html/test/vendor/magento/module-backend/App/AbstractAction.php(235): MagentoFrameworkAppActionAction->dispatch(Object(MagentoFrameworkAppRequestHttp))
#16 /var/www/html/test/vendor/magento/framework/Interception/Interceptor.php(58): MagentoBackendAppAbstractAction->dispatch(Object(MagentoFrameworkAppRequestHttp))
#17 /var/www/html/test/vendor/magento/framework/Interception/Interceptor.php(138): VendorNameModuleNameControllerAdminhtmlEntityNameSaveInterceptor->___callParent('dispatch', Array)
#18 /var/www/html/test/vendor/magento/module-backend/App/Action/Plugin/Authentication.php(143): VendorNameModuleNameControllerAdminhtmlEntityNameSaveInterceptor->MagentoFrameworkInterception{closure}(Object(MagentoFrameworkAppRequestHttp))
#19 /var/www/html/test/vendor/magento/framework/Interception/Interceptor.php(135): MagentoBackendAppActionPluginAuthentication->aroundDispatch(Object(VendorNameModuleNameControllerAdminhtmlEntityNameSaveInterceptor), Object(Closure), Object(MagentoFrameworkAppRequestHttp))
#20 /var/www/html/test/vendor/magento/framework/Interception/Interceptor.php(153): VendorNameModuleNameControllerAdminhtmlEntityNameSaveInterceptor->MagentoFrameworkInterception{closure}(Object(MagentoFrameworkAppRequestHttp))
#21 /var/www/html/test/generated/code/VendorName/ModuleName/Controller/Adminhtml/EntityName/Save/Interceptor.php(39): VendorNameModuleNameControllerAdminhtmlEntityNameSaveInterceptor->___callPlugins('dispatch', Array, NULL)
#22 /var/www/html/test/vendor/magento/framework/App/FrontController.php(55): VendorNameModuleNameControllerAdminhtmlEntityNameSaveInterceptor->dispatch(Object(MagentoFrameworkAppRequestHttp))
#23 /var/www/html/test/vendor/magento/framework/Interception/Interceptor.php(58): MagentoFrameworkAppFrontController->dispatch(Object(MagentoFrameworkAppRequestHttp))
#24 /var/www/html/test/vendor/magento/framework/Interception/Interceptor.php(138): MagentoFrameworkAppFrontControllerInterceptor->___callParent('dispatch', Array)
#25 /var/www/html/test/vendor/magento/framework/Interception/Interceptor.php(153): MagentoFrameworkAppFrontControllerInterceptor->MagentoFrameworkInterception{closure}(Object(MagentoFrameworkAppRequestHttp))
#26 /var/www/html/test/generated/code/Magento/Framework/App/FrontController/Interceptor.php(26): MagentoFrameworkAppFrontControllerInterceptor->___callPlugins('dispatch', Array, Array)
#27 /var/www/html/test/vendor/magento/framework/App/Http.php(135): MagentoFrameworkAppFrontControllerInterceptor->dispatch(Object(MagentoFrameworkAppRequestHttp))
#28 /var/www/html/test/generated/code/Magento/Framework/App/Http/Interceptor.php(24): MagentoFrameworkAppHttp->launch()
#29 /var/www/html/test/vendor/magento/framework/App/Bootstrap.php(257): MagentoFrameworkAppHttpInterceptor->launch()
#30 /var/www/html/test/index.php(39): MagentoFrameworkAppBootstrap->run(Object(MagentoFrameworkAppHttpInterceptor))
#31 {main} [] []
[2019-03-18 04:47:03] main.CRITICAL: Exception message: Invalid method MagentoEavModelEntityAttribute::isScopeStore
Trace: #0 /var/www/html/test/app/code/VendorName/ModuleName/Model/ResourceModel/EntityName.php(147): MagentoFrameworkDataObject->__call('isScopeStore', Array)
#1 /var/www/html/test/vendor/magento/module-eav/Model/Entity/AbstractEntity.php(1536): VendorNameModuleNameModelResourceModelEntityName->_saveAttribute(Object(VendorNameModuleNameModelEntityName), Object(MagentoEavModelEntityAttribute), '0')
#2 /var/www/html/test/vendor/magento/module-eav/Model/Entity/AbstractEntity.php(1496): MagentoEavModelEntityAbstractEntity->_insertAttribute(Object(VendorNameModuleNameModelEntityName), Object(MagentoEavModelEntityAttribute), '0')
#3 /var/www/html/test/vendor/magento/module-eav/Model/Entity/AbstractEntity.php(1227): MagentoEavModelEntityAbstractEntity->_processSaveData(Array)
#4 /var/www/html/test/vendor/magento/module-eav/Model/Entity/AbstractEntity.php(1198): MagentoEavModelEntityAbstractEntity->processSave(Object(VendorNameModuleNameModelEntityName))
#5 /var/www/html/test/vendor/magento/framework/Interception/Interceptor.php(58): MagentoEavModelEntityAbstractEntity->save(Object(VendorNameModuleNameModelEntityName))
#6 /var/www/html/test/vendor/magento/framework/Interception/Interceptor.php(138): VendorNameModuleNameModelResourceModelEntityNameInterceptor->___callParent('save', Array)
#7 /var/www/html/test/vendor/magento/framework/App/Cache/FlushCacheByTags.php(68): VendorNameModuleNameModelResourceModelEntityNameInterceptor->MagentoFrameworkInterception{closure}(Object(VendorNameModuleNameModelEntityName))
#8 /var/www/html/test/vendor/magento/framework/Interception/Interceptor.php(135): MagentoFrameworkAppCacheFlushCacheByTags->aroundSave(Object(VendorNameModuleNameModelResourceModelEntityNameInterceptor), Object(Closure), Object(VendorNameModuleNameModelEntityName))
#9 /var/www/html/test/vendor/magento/framework/Interception/Interceptor.php(153): VendorNameModuleNameModelResourceModelEntityNameInterceptor->MagentoFrameworkInterception{closure}(Object(VendorNameModuleNameModelEntityName))
#10 /var/www/html/test/generated/code/VendorName/ModuleName/Model/ResourceModel/EntityName/Interceptor.php(468): VendorNameModuleNameModelResourceModelEntityNameInterceptor->___callPlugins('save', Array, NULL)
#11 /var/www/html/test/vendor/magento/framework/Model/AbstractModel.php(647): VendorNameModuleNameModelResourceModelEntityNameInterceptor->save(Object(VendorNameModuleNameModelEntityName))
#12 /var/www/html/test/app/code/VendorName/ModuleName/Controller/Adminhtml/EntityName/Save.php(86): MagentoFrameworkModelAbstractModel->save()
#13 /var/www/html/test/generated/code/VendorName/ModuleName/Controller/Adminhtml/EntityName/Save/Interceptor.php(24): VendorNameModuleNameControllerAdminhtmlEntityNameSave->execute()
#14 /var/www/html/test/vendor/magento/framework/App/Action/Action.php(107): VendorNameModuleNameControllerAdminhtmlEntityNameSaveInterceptor->execute()
#15 /var/www/html/test/vendor/magento/module-backend/App/AbstractAction.php(235): MagentoFrameworkAppActionAction->dispatch(Object(MagentoFrameworkAppRequestHttp))
#16 /var/www/html/test/vendor/magento/framework/Interception/Interceptor.php(58): MagentoBackendAppAbstractAction->dispatch(Object(MagentoFrameworkAppRequestHttp))
#17 /var/www/html/test/vendor/magento/framework/Interception/Interceptor.php(138): VendorNameModuleNameControllerAdminhtmlEntityNameSaveInterceptor->___callParent('dispatch', Array)
#18 /var/www/html/test/vendor/magento/module-backend/App/Action/Plugin/Authentication.php(143): VendorNameModuleNameControllerAdminhtmlEntityNameSaveInterceptor->MagentoFrameworkInterception{closure}(Object(MagentoFrameworkAppRequestHttp))
#19 /var/www/html/test/vendor/magento/framework/Interception/Interceptor.php(135): MagentoBackendAppActionPluginAuthentication->aroundDispatch(Object(VendorNameModuleNameControllerAdminhtmlEntityNameSaveInterceptor), Object(Closure), Object(MagentoFrameworkAppRequestHttp))
#20 /var/www/html/test/vendor/magento/framework/Interception/Interceptor.php(153): VendorNameModuleNameControllerAdminhtmlEntityNameSaveInterceptor->MagentoFrameworkInterception{closure}(Object(MagentoFrameworkAppRequestHttp))
#21 /var/www/html/test/generated/code/VendorName/ModuleName/Controller/Adminhtml/EntityName/Save/Interceptor.php(39): VendorNameModuleNameControllerAdminhtmlEntityNameSaveInterceptor->___callPlugins('dispatch', Array, NULL)
#22 /var/www/html/test/vendor/magento/framework/App/FrontController.php(55): VendorNameModuleNameControllerAdminhtmlEntityNameSaveInterceptor->dispatch(Object(MagentoFrameworkAppRequestHttp))
#23 /var/www/html/test/vendor/magento/framework/Interception/Interceptor.php(58): MagentoFrameworkAppFrontController->dispatch(Object(MagentoFrameworkAppRequestHttp))
#24 /var/www/html/test/vendor/magento/framework/Interception/Interceptor.php(138): MagentoFrameworkAppFrontControllerInterceptor->___callParent('dispatch', Array)
#25 /var/www/html/test/vendor/magento/framework/Interception/Interceptor.php(153): MagentoFrameworkAppFrontControllerInterceptor->MagentoFrameworkInterception{closure}(Object(MagentoFrameworkAppRequestHttp))
#26 /var/www/html/test/generated/code/Magento/Framework/App/FrontController/Interceptor.php(26): MagentoFrameworkAppFrontControllerInterceptor->___callPlugins('dispatch', Array, Array)
#27 /var/www/html/test/vendor/magento/framework/App/Http.php(135): MagentoFrameworkAppFrontControllerInterceptor->dispatch(Object(MagentoFrameworkAppRequestHttp))
#28 /var/www/html/test/generated/code/Magento/Framework/App/Http/Interceptor.php(24): MagentoFrameworkAppHttp->launch()
#29 /var/www/html/test/vendor/magento/framework/App/Bootstrap.php(257): MagentoFrameworkAppHttpInterceptor->launch()
#30 /var/www/html/test/index.php(39): MagentoFrameworkAppBootstrap->run(Object(MagentoFrameworkAppHttpInterceptor))
#31 {main} [] []
/app/code/VendorName/ModuleName/Model/ResourceModel/EntityName.php
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace VendorNameModuleNameModelResourceModel;
use MagentoEavModelEntityAbstractEntity;
use MagentoEavModelEntityContext;
use MagentoFrameworkDataObject;
use MagentoStoreModelStore;
use MagentoStoreModelStoreManagerInterface;
use VendorNameModuleNameSetupEntitySetup;
class EntityName extends AbstractEntity {
/**
* Store id
*
* @var int
*/
protected $_storeId = null;
/**
* @var StoreManagerInterface
*/
protected $_storeManager;
/**
* @var EntityManager
*/
protected $entityManager;
/**
* [__construct description]
* @param Context $context [description]
* @param StoreManagerInterface $storeManager [description]
* @param array $data [description]
*/
public function __construct(
Context $context,
StoreManagerInterface $storeManager,
array $data = []
) {
parent::__construct($context, $data);
$this->setType(EntitySetup::ENTITY_TYPE_CODE);
$this->setConnection(EntitySetup::ENTITY_TYPE_CODE . '_read', EntitySetup::ENTITY_TYPE_CODE . '_write');
$this->_storeManager = $storeManager;
}
/**
* Set attribute set id and entity type id value
*
* @param MagentoFrameworkDataObject $customer
* @return $this
* @throws MagentoFrameworkExceptionLocalizedException
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
protected function _beforeSave(MagentoFrameworkDataObject $object) {
$object->setAttributeSetId($object->getAttributeSetId() ?: $this->getEntityType()->getDefaultAttributeSetId());
$object->setEntityTypeId($object->getEntityTypeId() ?: $this->getEntityType()->getEntityTypeId());
return parent::_beforeSave($object);
}
/**
* Return Entity Type instance
*
* @return MagentoEavModelEntityType
*/
public function getEntityType() {
if (empty($this->_type)) {
$this->setType(EntitySetup::ENTITY_TYPE_CODE);
}
return parent::getEntityType();
}
/**
* Retrieve ProductFaqNew entity default attributes
*
* @return string[]
*/
protected function _getDefaultAttributes() {
return [
'attribute_set_id',
'entity_type_id',
'created_at',
'updated_at',
];
}
/**
* Set store Id
*
* @param integer $storeId
* @return $this
*/
public function setStoreId($storeId) {
$this->_storeId = $storeId;
return $this;
}
/**
* Return store id
*
* @return integer
*/
public function getStoreId() {
if ($this->_storeId === null) {
return $this->_storeManager->getStore()->getId();
}
return $this->_storeId;
}
/**
* Set Attribute values to be saved
*
* @param MagentoFrameworkModelAbstractModel $object
* @param MagentoEavModelEntityAttributeAbstractAttribute $attribute
* @param mixed $value
* @return $this
*/
protected function _saveAttribute($object, $attribute, $value) {
$table = $attribute->getBackend()->getTable();
if (!isset($this->_attributeValuesToSave[$table])) {
$this->_attributeValuesToSave[$table] = [];
}
$entityIdField = $attribute->getBackend()->getEntityIdField();
$storeId = $object->getStoreId() ?: Store::DEFAULT_STORE_ID;
$data = [
$entityIdField => $object->getId(),
'entity_type_id' => $object->getEntityTypeId(),
'attribute_id' => $attribute->getId(),
'value' => $this->_prepareValueForSave($value, $attribute),
'store_id' => $storeId,
];
if (!$this->getEntityTable() || $this->getEntityTable() == MagentoEavModelEntity::DEFAULT_ENTITY_TABLE) {
$data['entity_type_id'] = $object->getEntityTypeId();
}
if ($attribute->isScopeStore()) {
/**
* Update attribute value for store
*/
$this->_attributeValuesToSave[$table][] = $data;
} elseif ($attribute->isScopeWebsite() && $storeId != Store::DEFAULT_STORE_ID) {
/**
* Update attribute value for website
*/
$storeIds = $this->_storeManager->getStore($storeId)->getWebsite()->getStoreIds(true);
foreach ($storeIds as $storeId) {
$data['store_id'] = (int) $storeId;
$this->_attributeValuesToSave[$table][] = $data;
}
} else {
/**
* Update global attribute value
*/
$data['store_id'] = Store::DEFAULT_STORE_ID;
$this->_attributeValuesToSave[$table][] = $data;
}
return $this;
}
}
what should I need to change?
Any help would be appriciated.
Thanks.
magento2 eav entity-manager
I am getting an issue on Magento 2.2.6 when trying to save my module record. This error occurs sometimes and the error disappears if run Magento upgrade command. But it comes again sometime.
system.log :
[2019-03-18 04:46:32] main.CRITICAL: Exception message: Invalid method MagentoEavModelEntityAttribute::isScopeStore
Trace: #0 /var/www/html/test/app/code/VendorName/ModuleName/Model/ResourceModel/EntityName.php(147): MagentoFrameworkDataObject->__call('isScopeStore', Array)
#1 /var/www/html/test/vendor/magento/module-eav/Model/Entity/AbstractEntity.php(1536): VendorNameModuleNameModelResourceModelEntityName->_saveAttribute(Object(VendorNameModuleNameModelEntityName), Object(MagentoEavModelEntityAttribute), '0')
#2 /var/www/html/test/vendor/magento/module-eav/Model/Entity/AbstractEntity.php(1496): MagentoEavModelEntityAbstractEntity->_insertAttribute(Object(VendorNameModuleNameModelEntityName), Object(MagentoEavModelEntityAttribute), '0')
#3 /var/www/html/test/vendor/magento/module-eav/Model/Entity/AbstractEntity.php(1227): MagentoEavModelEntityAbstractEntity->_processSaveData(Array)
#4 /var/www/html/test/vendor/magento/module-eav/Model/Entity/AbstractEntity.php(1198): MagentoEavModelEntityAbstractEntity->processSave(Object(VendorNameModuleNameModelEntityName))
#5 /var/www/html/test/vendor/magento/framework/Interception/Interceptor.php(58): MagentoEavModelEntityAbstractEntity->save(Object(VendorNameModuleNameModelEntityName))
#6 /var/www/html/test/vendor/magento/framework/Interception/Interceptor.php(138): VendorNameModuleNameModelResourceModelEntityNameInterceptor->___callParent('save', Array)
#7 /var/www/html/test/vendor/magento/framework/App/Cache/FlushCacheByTags.php(68): VendorNameModuleNameModelResourceModelEntityNameInterceptor->MagentoFrameworkInterception{closure}(Object(VendorNameModuleNameModelEntityName))
#8 /var/www/html/test/vendor/magento/framework/Interception/Interceptor.php(135): MagentoFrameworkAppCacheFlushCacheByTags->aroundSave(Object(VendorNameModuleNameModelResourceModelEntityNameInterceptor), Object(Closure), Object(VendorNameModuleNameModelEntityName))
#9 /var/www/html/test/vendor/magento/framework/Interception/Interceptor.php(153): VendorNameModuleNameModelResourceModelEntityNameInterceptor->MagentoFrameworkInterception{closure}(Object(VendorNameModuleNameModelEntityName))
#10 /var/www/html/test/generated/code/VendorName/ModuleName/Model/ResourceModel/EntityName/Interceptor.php(468): VendorNameModuleNameModelResourceModelEntityNameInterceptor->___callPlugins('save', Array, NULL)
#11 /var/www/html/test/vendor/magento/framework/Model/AbstractModel.php(647): VendorNameModuleNameModelResourceModelEntityNameInterceptor->save(Object(VendorNameModuleNameModelEntityName))
#12 /var/www/html/test/app/code/VendorName/ModuleName/Controller/Adminhtml/EntityName/Save.php(86): MagentoFrameworkModelAbstractModel->save()
#13 /var/www/html/test/generated/code/VendorName/ModuleName/Controller/Adminhtml/EntityName/Save/Interceptor.php(24): VendorNameModuleNameControllerAdminhtmlEntityNameSave->execute()
#14 /var/www/html/test/vendor/magento/framework/App/Action/Action.php(107): VendorNameModuleNameControllerAdminhtmlEntityNameSaveInterceptor->execute()
#15 /var/www/html/test/vendor/magento/module-backend/App/AbstractAction.php(235): MagentoFrameworkAppActionAction->dispatch(Object(MagentoFrameworkAppRequestHttp))
#16 /var/www/html/test/vendor/magento/framework/Interception/Interceptor.php(58): MagentoBackendAppAbstractAction->dispatch(Object(MagentoFrameworkAppRequestHttp))
#17 /var/www/html/test/vendor/magento/framework/Interception/Interceptor.php(138): VendorNameModuleNameControllerAdminhtmlEntityNameSaveInterceptor->___callParent('dispatch', Array)
#18 /var/www/html/test/vendor/magento/module-backend/App/Action/Plugin/Authentication.php(143): VendorNameModuleNameControllerAdminhtmlEntityNameSaveInterceptor->MagentoFrameworkInterception{closure}(Object(MagentoFrameworkAppRequestHttp))
#19 /var/www/html/test/vendor/magento/framework/Interception/Interceptor.php(135): MagentoBackendAppActionPluginAuthentication->aroundDispatch(Object(VendorNameModuleNameControllerAdminhtmlEntityNameSaveInterceptor), Object(Closure), Object(MagentoFrameworkAppRequestHttp))
#20 /var/www/html/test/vendor/magento/framework/Interception/Interceptor.php(153): VendorNameModuleNameControllerAdminhtmlEntityNameSaveInterceptor->MagentoFrameworkInterception{closure}(Object(MagentoFrameworkAppRequestHttp))
#21 /var/www/html/test/generated/code/VendorName/ModuleName/Controller/Adminhtml/EntityName/Save/Interceptor.php(39): VendorNameModuleNameControllerAdminhtmlEntityNameSaveInterceptor->___callPlugins('dispatch', Array, NULL)
#22 /var/www/html/test/vendor/magento/framework/App/FrontController.php(55): VendorNameModuleNameControllerAdminhtmlEntityNameSaveInterceptor->dispatch(Object(MagentoFrameworkAppRequestHttp))
#23 /var/www/html/test/vendor/magento/framework/Interception/Interceptor.php(58): MagentoFrameworkAppFrontController->dispatch(Object(MagentoFrameworkAppRequestHttp))
#24 /var/www/html/test/vendor/magento/framework/Interception/Interceptor.php(138): MagentoFrameworkAppFrontControllerInterceptor->___callParent('dispatch', Array)
#25 /var/www/html/test/vendor/magento/framework/Interception/Interceptor.php(153): MagentoFrameworkAppFrontControllerInterceptor->MagentoFrameworkInterception{closure}(Object(MagentoFrameworkAppRequestHttp))
#26 /var/www/html/test/generated/code/Magento/Framework/App/FrontController/Interceptor.php(26): MagentoFrameworkAppFrontControllerInterceptor->___callPlugins('dispatch', Array, Array)
#27 /var/www/html/test/vendor/magento/framework/App/Http.php(135): MagentoFrameworkAppFrontControllerInterceptor->dispatch(Object(MagentoFrameworkAppRequestHttp))
#28 /var/www/html/test/generated/code/Magento/Framework/App/Http/Interceptor.php(24): MagentoFrameworkAppHttp->launch()
#29 /var/www/html/test/vendor/magento/framework/App/Bootstrap.php(257): MagentoFrameworkAppHttpInterceptor->launch()
#30 /var/www/html/test/index.php(39): MagentoFrameworkAppBootstrap->run(Object(MagentoFrameworkAppHttpInterceptor))
#31 {main} [] []
[2019-03-18 04:47:03] main.CRITICAL: Exception message: Invalid method MagentoEavModelEntityAttribute::isScopeStore
Trace: #0 /var/www/html/test/app/code/VendorName/ModuleName/Model/ResourceModel/EntityName.php(147): MagentoFrameworkDataObject->__call('isScopeStore', Array)
#1 /var/www/html/test/vendor/magento/module-eav/Model/Entity/AbstractEntity.php(1536): VendorNameModuleNameModelResourceModelEntityName->_saveAttribute(Object(VendorNameModuleNameModelEntityName), Object(MagentoEavModelEntityAttribute), '0')
#2 /var/www/html/test/vendor/magento/module-eav/Model/Entity/AbstractEntity.php(1496): MagentoEavModelEntityAbstractEntity->_insertAttribute(Object(VendorNameModuleNameModelEntityName), Object(MagentoEavModelEntityAttribute), '0')
#3 /var/www/html/test/vendor/magento/module-eav/Model/Entity/AbstractEntity.php(1227): MagentoEavModelEntityAbstractEntity->_processSaveData(Array)
#4 /var/www/html/test/vendor/magento/module-eav/Model/Entity/AbstractEntity.php(1198): MagentoEavModelEntityAbstractEntity->processSave(Object(VendorNameModuleNameModelEntityName))
#5 /var/www/html/test/vendor/magento/framework/Interception/Interceptor.php(58): MagentoEavModelEntityAbstractEntity->save(Object(VendorNameModuleNameModelEntityName))
#6 /var/www/html/test/vendor/magento/framework/Interception/Interceptor.php(138): VendorNameModuleNameModelResourceModelEntityNameInterceptor->___callParent('save', Array)
#7 /var/www/html/test/vendor/magento/framework/App/Cache/FlushCacheByTags.php(68): VendorNameModuleNameModelResourceModelEntityNameInterceptor->MagentoFrameworkInterception{closure}(Object(VendorNameModuleNameModelEntityName))
#8 /var/www/html/test/vendor/magento/framework/Interception/Interceptor.php(135): MagentoFrameworkAppCacheFlushCacheByTags->aroundSave(Object(VendorNameModuleNameModelResourceModelEntityNameInterceptor), Object(Closure), Object(VendorNameModuleNameModelEntityName))
#9 /var/www/html/test/vendor/magento/framework/Interception/Interceptor.php(153): VendorNameModuleNameModelResourceModelEntityNameInterceptor->MagentoFrameworkInterception{closure}(Object(VendorNameModuleNameModelEntityName))
#10 /var/www/html/test/generated/code/VendorName/ModuleName/Model/ResourceModel/EntityName/Interceptor.php(468): VendorNameModuleNameModelResourceModelEntityNameInterceptor->___callPlugins('save', Array, NULL)
#11 /var/www/html/test/vendor/magento/framework/Model/AbstractModel.php(647): VendorNameModuleNameModelResourceModelEntityNameInterceptor->save(Object(VendorNameModuleNameModelEntityName))
#12 /var/www/html/test/app/code/VendorName/ModuleName/Controller/Adminhtml/EntityName/Save.php(86): MagentoFrameworkModelAbstractModel->save()
#13 /var/www/html/test/generated/code/VendorName/ModuleName/Controller/Adminhtml/EntityName/Save/Interceptor.php(24): VendorNameModuleNameControllerAdminhtmlEntityNameSave->execute()
#14 /var/www/html/test/vendor/magento/framework/App/Action/Action.php(107): VendorNameModuleNameControllerAdminhtmlEntityNameSaveInterceptor->execute()
#15 /var/www/html/test/vendor/magento/module-backend/App/AbstractAction.php(235): MagentoFrameworkAppActionAction->dispatch(Object(MagentoFrameworkAppRequestHttp))
#16 /var/www/html/test/vendor/magento/framework/Interception/Interceptor.php(58): MagentoBackendAppAbstractAction->dispatch(Object(MagentoFrameworkAppRequestHttp))
#17 /var/www/html/test/vendor/magento/framework/Interception/Interceptor.php(138): VendorNameModuleNameControllerAdminhtmlEntityNameSaveInterceptor->___callParent('dispatch', Array)
#18 /var/www/html/test/vendor/magento/module-backend/App/Action/Plugin/Authentication.php(143): VendorNameModuleNameControllerAdminhtmlEntityNameSaveInterceptor->MagentoFrameworkInterception{closure}(Object(MagentoFrameworkAppRequestHttp))
#19 /var/www/html/test/vendor/magento/framework/Interception/Interceptor.php(135): MagentoBackendAppActionPluginAuthentication->aroundDispatch(Object(VendorNameModuleNameControllerAdminhtmlEntityNameSaveInterceptor), Object(Closure), Object(MagentoFrameworkAppRequestHttp))
#20 /var/www/html/test/vendor/magento/framework/Interception/Interceptor.php(153): VendorNameModuleNameControllerAdminhtmlEntityNameSaveInterceptor->MagentoFrameworkInterception{closure}(Object(MagentoFrameworkAppRequestHttp))
#21 /var/www/html/test/generated/code/VendorName/ModuleName/Controller/Adminhtml/EntityName/Save/Interceptor.php(39): VendorNameModuleNameControllerAdminhtmlEntityNameSaveInterceptor->___callPlugins('dispatch', Array, NULL)
#22 /var/www/html/test/vendor/magento/framework/App/FrontController.php(55): VendorNameModuleNameControllerAdminhtmlEntityNameSaveInterceptor->dispatch(Object(MagentoFrameworkAppRequestHttp))
#23 /var/www/html/test/vendor/magento/framework/Interception/Interceptor.php(58): MagentoFrameworkAppFrontController->dispatch(Object(MagentoFrameworkAppRequestHttp))
#24 /var/www/html/test/vendor/magento/framework/Interception/Interceptor.php(138): MagentoFrameworkAppFrontControllerInterceptor->___callParent('dispatch', Array)
#25 /var/www/html/test/vendor/magento/framework/Interception/Interceptor.php(153): MagentoFrameworkAppFrontControllerInterceptor->MagentoFrameworkInterception{closure}(Object(MagentoFrameworkAppRequestHttp))
#26 /var/www/html/test/generated/code/Magento/Framework/App/FrontController/Interceptor.php(26): MagentoFrameworkAppFrontControllerInterceptor->___callPlugins('dispatch', Array, Array)
#27 /var/www/html/test/vendor/magento/framework/App/Http.php(135): MagentoFrameworkAppFrontControllerInterceptor->dispatch(Object(MagentoFrameworkAppRequestHttp))
#28 /var/www/html/test/generated/code/Magento/Framework/App/Http/Interceptor.php(24): MagentoFrameworkAppHttp->launch()
#29 /var/www/html/test/vendor/magento/framework/App/Bootstrap.php(257): MagentoFrameworkAppHttpInterceptor->launch()
#30 /var/www/html/test/index.php(39): MagentoFrameworkAppBootstrap->run(Object(MagentoFrameworkAppHttpInterceptor))
#31 {main} [] []
/app/code/VendorName/ModuleName/Model/ResourceModel/EntityName.php
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace VendorNameModuleNameModelResourceModel;
use MagentoEavModelEntityAbstractEntity;
use MagentoEavModelEntityContext;
use MagentoFrameworkDataObject;
use MagentoStoreModelStore;
use MagentoStoreModelStoreManagerInterface;
use VendorNameModuleNameSetupEntitySetup;
class EntityName extends AbstractEntity {
/**
* Store id
*
* @var int
*/
protected $_storeId = null;
/**
* @var StoreManagerInterface
*/
protected $_storeManager;
/**
* @var EntityManager
*/
protected $entityManager;
/**
* [__construct description]
* @param Context $context [description]
* @param StoreManagerInterface $storeManager [description]
* @param array $data [description]
*/
public function __construct(
Context $context,
StoreManagerInterface $storeManager,
array $data = []
) {
parent::__construct($context, $data);
$this->setType(EntitySetup::ENTITY_TYPE_CODE);
$this->setConnection(EntitySetup::ENTITY_TYPE_CODE . '_read', EntitySetup::ENTITY_TYPE_CODE . '_write');
$this->_storeManager = $storeManager;
}
/**
* Set attribute set id and entity type id value
*
* @param MagentoFrameworkDataObject $customer
* @return $this
* @throws MagentoFrameworkExceptionLocalizedException
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
protected function _beforeSave(MagentoFrameworkDataObject $object) {
$object->setAttributeSetId($object->getAttributeSetId() ?: $this->getEntityType()->getDefaultAttributeSetId());
$object->setEntityTypeId($object->getEntityTypeId() ?: $this->getEntityType()->getEntityTypeId());
return parent::_beforeSave($object);
}
/**
* Return Entity Type instance
*
* @return MagentoEavModelEntityType
*/
public function getEntityType() {
if (empty($this->_type)) {
$this->setType(EntitySetup::ENTITY_TYPE_CODE);
}
return parent::getEntityType();
}
/**
* Retrieve ProductFaqNew entity default attributes
*
* @return string[]
*/
protected function _getDefaultAttributes() {
return [
'attribute_set_id',
'entity_type_id',
'created_at',
'updated_at',
];
}
/**
* Set store Id
*
* @param integer $storeId
* @return $this
*/
public function setStoreId($storeId) {
$this->_storeId = $storeId;
return $this;
}
/**
* Return store id
*
* @return integer
*/
public function getStoreId() {
if ($this->_storeId === null) {
return $this->_storeManager->getStore()->getId();
}
return $this->_storeId;
}
/**
* Set Attribute values to be saved
*
* @param MagentoFrameworkModelAbstractModel $object
* @param MagentoEavModelEntityAttributeAbstractAttribute $attribute
* @param mixed $value
* @return $this
*/
protected function _saveAttribute($object, $attribute, $value) {
$table = $attribute->getBackend()->getTable();
if (!isset($this->_attributeValuesToSave[$table])) {
$this->_attributeValuesToSave[$table] = [];
}
$entityIdField = $attribute->getBackend()->getEntityIdField();
$storeId = $object->getStoreId() ?: Store::DEFAULT_STORE_ID;
$data = [
$entityIdField => $object->getId(),
'entity_type_id' => $object->getEntityTypeId(),
'attribute_id' => $attribute->getId(),
'value' => $this->_prepareValueForSave($value, $attribute),
'store_id' => $storeId,
];
if (!$this->getEntityTable() || $this->getEntityTable() == MagentoEavModelEntity::DEFAULT_ENTITY_TABLE) {
$data['entity_type_id'] = $object->getEntityTypeId();
}
if ($attribute->isScopeStore()) {
/**
* Update attribute value for store
*/
$this->_attributeValuesToSave[$table][] = $data;
} elseif ($attribute->isScopeWebsite() && $storeId != Store::DEFAULT_STORE_ID) {
/**
* Update attribute value for website
*/
$storeIds = $this->_storeManager->getStore($storeId)->getWebsite()->getStoreIds(true);
foreach ($storeIds as $storeId) {
$data['store_id'] = (int) $storeId;
$this->_attributeValuesToSave[$table][] = $data;
}
} else {
/**
* Update global attribute value
*/
$data['store_id'] = Store::DEFAULT_STORE_ID;
$this->_attributeValuesToSave[$table][] = $data;
}
return $this;
}
}
what should I need to change?
Any help would be appriciated.
Thanks.
magento2 eav entity-manager
magento2 eav entity-manager
asked 7 mins ago
Rohan HapaniRohan Hapani
6,56831864
6,56831864
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "479"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f266244%2fmagento-2-invalid-method-magento-eav-model-entity-attributeisscopestore%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f266244%2fmagento-2-invalid-method-magento-eav-model-entity-attributeisscopestore%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown