public function testGetAttributes()
 {
     $attributes = $this->_model->getAttributes();
     $this->assertArrayHasKey('name', $attributes);
     $this->assertArrayHasKey('custom_design', $attributes);
     $attributes = $this->_model->getAttributes(true);
     $this->assertArrayHasKey('name', $attributes);
     $this->assertArrayNotHasKey('custom_design', $attributes);
 }
Example #2
0
 /**
  * {@inheritdoc}
  */
 public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
 {
     if (version_compare($context->getVersion(), '2.0.0.2') < 0) {
         $newBackendModel = 'Magento\\Catalog\\Model\\Attribute\\Backend\\Startdate';
         $connection = $setup->getConnection();
         $connection->startSetup();
         $connection->update($setup->getTable('eav_attribute'), ['backend_model' => $newBackendModel], ['backend_model = ?' => 'Magento\\Catalog\\Model\\Product\\Attribute\\Backend\\Startdate']);
         /** @var \Magento\Catalog\Model\Resource\Eav\Attribute $attribute */
         foreach ($this->category->getAttributes() as $attribute) {
             if ($attribute->getAttributeCode() == 'custom_design_from') {
                 $attribute->setBackendModel($newBackendModel);
                 $attribute->save();
                 break;
             }
         }
         $connection->endSetup();
     }
 }
Example #3
0
 /**
  * Datetime data preprocessing
  *
  * @param \Magento\Catalog\Model\Category $category
  * @param array $postData
  *
  * @return array
  */
 protected function dateTimePreprocessing($category, $postData)
 {
     $dateFieldFilters = [];
     $attributes = $category->getAttributes();
     foreach ($attributes as $attrKey => $attribute) {
         if ($attribute->getBackend()->getType() == 'datetime') {
             if (array_key_exists($attrKey, $postData) && $postData[$attrKey] != '') {
                 $dateFieldFilters[$attrKey] = $this->getDateTimeFilter();
             }
         }
     }
     $inputFilter = new \Zend_Filter_Input($dateFieldFilters, [], $postData);
     return $inputFilter->getUnescaped();
 }
 /**
  * {@inheritdoc}
  */
 public function getAttributes($noDesignAttributes = false)
 {
     $pluginInfo = $this->pluginList->getNext($this->subjectType, 'getAttributes');
     if (!$pluginInfo) {
         return parent::getAttributes($noDesignAttributes);
     } else {
         return $this->___callPlugins('getAttributes', func_get_args(), $pluginInfo);
     }
 }