Пример #1
0
 /**
  * Retrieve attribute store identifiers
  *
  * @param \Magento\Eav\Model\Attribute|int $attribute
  * @return array
  */
 public function getStoreIds($attribute)
 {
     $adapter = $this->getConnection();
     if ($attribute instanceof \Magento\Eav\Model\Attribute) {
         $attributeId = $attribute->getId();
     } else {
         $attributeId = $attribute;
     }
     $select = $adapter->select()->from($this->getMainTable(), 'store_id')->where('attribute_id = ?', (int) $attributeId);
     return $adapter->fetchCol($select);
 }
Пример #2
0
 /**
  * Return attribute data model by attribute
  * Set entity to data model (need for work)
  *
  * @param \Magento\Eav\Model\Attribute $attribute
  * @param \Magento\Framework\Model\AbstractModel $entity
  * @return \Magento\Eav\Model\Attribute\Data\AbstractData
  */
 public function create(\Magento\Eav\Model\Attribute $attribute, \Magento\Framework\Model\AbstractModel $entity)
 {
     /* @var $dataModel \Magento\Eav\Model\Attribute\Data\AbstractData */
     $dataModelClass = $attribute->getDataModel();
     if (!empty($dataModelClass)) {
         if (empty($this->_dataModels[$dataModelClass])) {
             $dataModel = $this->_objectManager->create($dataModelClass);
             $this->_dataModels[$dataModelClass] = $dataModel;
         } else {
             $dataModel = $this->_dataModels[$dataModelClass];
         }
     } else {
         if (empty($this->_dataModels[$attribute->getFrontendInput()])) {
             $dataModelClass = sprintf('Magento\\Eav\\Model\\Attribute\\Data\\%s', $this->string->upperCaseWords($attribute->getFrontendInput()));
             $dataModel = $this->_objectManager->create($dataModelClass);
             $this->_dataModels[$attribute->getFrontendInput()] = $dataModel;
         } else {
             $dataModel = $this->_dataModels[$attribute->getFrontendInput()];
         }
     }
     $dataModel->setAttribute($attribute);
     $dataModel->setEntity($entity);
     return $dataModel;
 }
Пример #3
0
 public function testSendNewAccountEmailWithoutStoreId()
 {
     $store = $this->getMock('Magento\\Store\\Model\\Store', [], [], '', false);
     $website = $this->getMock('Magento\\Store\\Model\\Website', [], [], '', false);
     $website->expects($this->once())->method('getStoreIds')->will($this->returnValue([1, 2, 3, 4]));
     $this->_storeManager->expects($this->once())->method('getWebsite')->with(1)->will($this->returnValue($website));
     $this->_storeManager->expects($this->once())->method('getStore')->with(1)->will($this->returnValue($store));
     $this->_config->expects($this->exactly(3))->method('getAttribute')->will($this->returnValue($this->_attribute));
     $this->_attribute->expects($this->exactly(3))->method('getIsVisible')->will($this->returnValue(true));
     $methods = ['setTemplateIdentifier', 'setTemplateOptions', 'setTemplateVars', 'setFrom', 'addTo'];
     foreach ($methods as $method) {
         $this->_transportBuilderMock->expects($this->once())->method($method)->will($this->returnSelf());
     }
     $transportMock = $this->getMock('Magento\\Framework\\Mail\\TransportInterface', [], [], '', false);
     $transportMock->expects($this->once())->method('sendMessage')->will($this->returnSelf());
     $this->_transportBuilderMock->expects($this->once())->method('getTransport')->will($this->returnValue($transportMock));
     $this->_model->setData(['website_id' => 1, 'store_id' => 1, 'email' => '*****@*****.**', 'firstname' => 'FirstName', 'lastname' => 'LastName', 'middlename' => 'MiddleName', 'prefix' => 'Prefix']);
     $this->_model->sendNewAccountEmail('registered');
 }
Пример #4
0
 /**
  * @return bool
  */
 protected function isShowEmptyResults()
 {
     return $this->eavAttribute->getIsFilterable() != self::FILTERABLE_WITH_RESULTS;
 }
Пример #5
0
 /**
  * Whether the specified attribute needs to skip rendering/validation
  *
  * @param \Magento\Eav\Model\Attribute $attribute
  * @return bool
  */
 protected function _isAttributeOmitted($attribute)
 {
     if ($this->_ignoreInvisible && !$attribute->getIsVisible()) {
         return true;
     }
     return false;
 }
Пример #6
0
 /**
  * @inheritdoc
  */
 public function __wakeup()
 {
     parent::__wakeup();
     $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
     $this->indexerRegistry = $objectManager->get(\Magento\Framework\Indexer\IndexerRegistry::class);
 }
Пример #7
0
 /**
  * Return scope values for attribute and website
  *
  * @param \Magento\Eav\Model\Attribute $object
  * @return array
  */
 public function getScopeValues(\Magento\Eav\Model\Attribute $object)
 {
     $adapter = $this->_getReadAdapter();
     $bind = array('attribute_id' => (int) $object->getId(), 'website_id' => (int) $object->getWebsite()->getId());
     $select = $adapter->select()->from($this->_getEavWebsiteTable())->where('attribute_id = :attribute_id')->where('website_id = :website_id')->limit(1);
     $result = $adapter->fetchRow($select, $bind);
     if (!$result) {
         $result = array();
     }
     return $result;
 }
Пример #8
0
 /**
  * Return scope values for attribute and website
  *
  * @param \Magento\Eav\Model\Attribute $object
  * @return array
  */
 public function getScopeValues(\Magento\Eav\Model\Attribute $object)
 {
     $connection = $this->getConnection();
     $bind = ['attribute_id' => (int) $object->getId(), 'website_id' => (int) $object->getWebsite()->getId()];
     $select = $connection->select()->from($this->_getEavWebsiteTable())->where('attribute_id = :attribute_id')->where('website_id = :website_id')->limit(1);
     $result = $connection->fetchRow($select, $bind);
     if (!$result) {
         $result = [];
     }
     return $result;
 }
Пример #9
0
 /**
  * Init indexing process after customer delete
  *
  * @return \Magento\Framework\Model\AbstractModel
  */
 public function afterDeleteCommit()
 {
     if ($this->getData(EavAttributeInterface::IS_USED_IN_GRID) == true) {
         $this->invalidate();
     }
     return parent::afterDeleteCommit();
 }