Esempio n. 1
0
 /**
  * test \Magento\CatalogUrlRewrite\Plugin\Catalog\Block\Adminhtml\Category\Tab\Attributes::afterGetAttributesMeta
  * @return void
  */
 public function testGetAttributesMeta()
 {
     $meta = $this->dataProvider->getAttributesMeta($this->entityType);
     $this->assertArrayHasKey('url_key', $meta);
     $this->assertEquals('text', $meta['url_key']['dataType']);
     $this->assertEquals('input', $meta['url_key']['formElement']);
     $this->assertEquals('1', $meta['url_key']['visible']);
     $this->assertEquals('0', $meta['url_key']['required']);
     $this->assertEquals('[STORE VIEW]', $meta['url_key']['scope_label']);
 }
 /**
  * test \Magento\CatalogUrlRewrite\Plugin\Catalog\Block\Adminhtml\Category\Tab\Attributes::afterGetAttributesMeta
  * @return void
  */
 public function testGetAttributesMeta()
 {
     $meta = $this->dataProvider->getMeta();
     $this->assertArrayHasKey('url_key', $meta['search_engine_optimization']['children']);
     $urlKeyData = $meta['search_engine_optimization']['children']['url_key']['arguments']['data']['config'];
     $this->assertEquals('text', $urlKeyData['dataType']);
     $this->assertEquals('input', $urlKeyData['formElement']);
     $this->assertEquals('1', $urlKeyData['visible']);
     $this->assertEquals('0', $urlKeyData['required']);
     $this->assertEquals('[STORE VIEW]', $urlKeyData['scopeLabel']);
 }
 /**
  * Append virtual rule and sorting product data.
  *
  * @param CategoryDataProvider $dataProvider Data provider.
  * @param \Closure             $proceed      Original method.
  *
  * @return array
  */
 public function aroundGetData(CategoryDataProvider $dataProvider, \Closure $proceed)
 {
     $data = $proceed();
     $currentCategory = $dataProvider->getCurrentCategory();
     if ($currentCategory->getId() === null || $currentCategory->getLevel() < 2) {
         $data[$currentCategory->getId()]['use_default']['is_virtual_category'] = true;
     }
     $data[$currentCategory->getId()]['sorted_products'] = $this->getProductSavedPositions($currentCategory);
     $data[$currentCategory->getId()]['product_sorter_load_url'] = $this->getProductSorterLoadUrl($currentCategory);
     $data[$currentCategory->getId()]['price_format'] = $this->localeFormat->getPriceFormat();
     return $data;
 }
Esempio n. 4
0
 /**
  * @return void
  */
 public function testGetMetaRequiredAttributes()
 {
     $requiredAttributes = ['general' => ['name'], 'display_settings' => ['available_sort_by', 'default_sort_by']];
     $meta = $this->dataProvider->getMeta();
     $this->assertArrayHasKey('url_key', $meta['search_engine_optimization']['children']);
     foreach ($requiredAttributes as $scope => $attributes) {
         foreach ($attributes as $attribute) {
             $this->assertArrayHasKey($attribute, $meta[$scope]['children']);
             $data = $meta[$scope]['children'][$attribute];
             $this->assertTrue($data['arguments']['data']['config']['validation']['required-entry']);
         }
     }
 }
Esempio n. 5
0
 /**
  * @param \Magento\Catalog\Model\Category\DataProvider $subject
  * @param array $result
  *
  * @return array
  */
 public function afterGetAttributesMeta(\Magento\Catalog\Model\Category\DataProvider $subject, $result)
 {
     /** @var \Magento\Catalog\Model\Category $category */
     $category = $subject->getCurrentCategory();
     if (isset($result['url_key'])) {
         if ($category && $category->getId()) {
             if ($category->getLevel() == 1) {
                 $result['url_key_group']['componentDisabled'] = true;
             } else {
                 $result['url_key_create_redirect']['valueMap']['true'] = $category->getUrlKey();
                 $result['url_key_create_redirect']['value'] = $category->getUrlKey();
                 $result['url_key_create_redirect']['disabled'] = true;
             }
         } else {
             $result['url_key_create_redirect']['visible'] = false;
         }
     }
     return $result;
 }