Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Website.php
Go to the documentation of this file.
1 <?php
7 
13 class Website extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend
14 {
18  protected $_storeManager;
19 
24  {
25  $this->_storeManager = $storeManager;
26  }
27 
34  public function beforeSave($object)
35  {
36  if ($object->getId()) {
37  return $this;
38  }
39 
40  if (!$object->hasData('website_id')) {
41  $object->setData('website_id', $this->_storeManager->getStore()->getWebsiteId());
42  }
43 
44  return $this;
45  }
46 }
$storeManager
__construct(\Magento\Store\Model\StoreManagerInterface $storeManager)
Definition: Website.php:23