Example #1
0
 public function testGetProductsPosition()
 {
     $this->assertEquals([], $this->_model->getProductsPosition());
     $this->_model->unsetData();
     $this->_model = $this->getCategoryByName('Category 2');
     $this->assertEquals([], $this->_model->getProductsPosition());
     $this->_model->unsetData();
     $this->_model = $this->getCategoryByName('Category 1.1.1');
     $this->assertNotEmpty($this->_model->getProductsPosition());
 }
 public function testGetProductsPosition()
 {
     $this->assertEquals([], $this->_model->getProductsPosition());
     $this->_model->unsetData();
     $this->_model->load(6);
     $this->assertEquals([], $this->_model->getProductsPosition());
     $this->_model->unsetData();
     $this->_model->load(4);
     $this->assertContains(1, $this->_model->getProductsPosition());
 }
 public function testIsInRootCategoryList()
 {
     $this->assertFalse($this->_model->isInRootCategoryList());
     $this->_model->unsetData();
     $this->_model->load(3);
     $this->assertTrue($this->_model->isInRootCategoryList());
 }
 /**
  * @magentoAppArea adminhtml
  */
 public function testDeleteChildren()
 {
     $this->_model->unsetData();
     $this->_model->load(4);
     $this->_model->setSkipDeleteChildren(true);
     $this->_model->delete();
     $this->_model->unsetData();
     $this->_model->load(5);
     $this->assertEquals($this->_model->getId(), 5);
     $this->_model->unsetData();
     $this->_model->load(3);
     $this->assertEquals($this->_model->getId(), 3);
     $this->_model->delete();
     $this->_model->unsetData();
     $this->_model->load(5);
     $this->assertEquals($this->_model->getId(), null);
 }
Example #5
0
 /**
  * Update path field
  *
  * @param \Magento\Catalog\Model\Category $object
  * @return $this
  */
 protected function _savePath($object)
 {
     if ($object->getId()) {
         $this->_getWriteAdapter()->update($this->getEntityTable(), array('path' => $object->getPath()), array('entity_id = ?' => $object->getId()));
         $object->unsetData('path_ids');
     }
     return $this;
 }
Example #6
0
 /**
  * Update path field
  *
  * @param \Magento\Catalog\Model\Category $object
  * @return $this
  */
 protected function _savePath($object)
 {
     if ($object->getId()) {
         $this->getConnection()->update($this->getEntityTable(), ['path' => $object->getPath()], ['entity_id = ?' => $object->getId()]);
         $object->unsetData('path_ids');
     }
     return $this;
 }
 /**
  * Validate category process
  *
  * @param  Category $category
  * @return void
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 protected function validateCategory(Category $category)
 {
     $useConfigFields = [];
     foreach ($this->useConfigFields as $field) {
         if (!$category->getData($field)) {
             $useConfigFields[] = $field;
         }
     }
     $category->setData('use_post_data_config', $useConfigFields);
     $validate = $category->validate();
     if ($validate !== true) {
         foreach ($validate as $code => $error) {
             if ($error === true) {
                 $attribute = $this->categoryResource->getAttribute($code)->getFrontend()->getLabel();
                 throw new \Magento\Framework\Exception\LocalizedException(__('Attribute "%1" is required.', $attribute));
             } else {
                 throw new \Magento\Framework\Exception\LocalizedException(__($error));
             }
         }
     }
     $category->unsetData('use_post_data_config');
 }
 /**
  * {@inheritdoc}
  */
 public function unsetData($key = null)
 {
     $pluginInfo = $this->pluginList->getNext($this->subjectType, 'unsetData');
     if (!$pluginInfo) {
         return parent::unsetData($key);
     } else {
         return $this->___callPlugins('unsetData', func_get_args(), $pluginInfo);
     }
 }