当前位置: 首页>>代码示例>>PHP>>正文


PHP Category::getData方法代码示例

本文整理汇总了PHP中Magento\Catalog\Model\Category::getData方法的典型用法代码示例。如果您正苦于以下问题:PHP Category::getData方法的具体用法?PHP Category::getData怎么用?PHP Category::getData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Magento\Catalog\Model\Category的用法示例。


在下文中一共展示了Category::getData方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: generateForAutogenerated

 /**
  * @param \Magento\UrlRewrite\Service\V1\Data\UrlRewrite $url
  * @param int $storeId
  * @return array
  */
 protected function generateForAutogenerated($url, $storeId)
 {
     $urls = [];
     if ($this->category->getData('save_rewrites_history')) {
         $targetPath = $this->categoryUrlPathGenerator->getUrlPathWithSuffix($this->category, $storeId);
         if ($url->getRequestPath() !== $targetPath) {
             $urls[$url->getRequestPath() . '_' . $storeId] = $this->urlRewriteFactory->create()->setEntityType(CategoryUrlRewriteGenerator::ENTITY_TYPE)->setEntityId($this->category->getId())->setRequestPath($url->getRequestPath())->setTargetPath($targetPath)->setRedirectType(OptionProvider::PERMANENT)->setStoreId($storeId)->setIsAutogenerated(0);
         }
     }
     return $urls;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:16,代码来源:CurrentUrlRewritesRegenerator.php

示例2: testGetCurrentCategoryIfCurrentCategoryIsNotSet

 public function testGetCurrentCategoryIfCurrentCategoryIsNotSet()
 {
     $rootCategoryId = 333;
     $this->currentCategory->getData('current_category', null);
     $this->registry->expects($this->once())->method('registry')->with($this->equalTo('current_category'))->willReturn(null);
     $this->categoryRepository->expects($this->once())->method('get')->with($rootCategoryId)->willReturn($this->category);
     $this->store->expects($this->any())->method('getRootCategoryId')->will($this->returnValue($rootCategoryId));
     $this->assertEquals($this->currentCategory, $this->model->getCurrentCategory());
     $this->assertEquals($this->currentCategory, $this->model->getData('current_category'));
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:10,代码来源:LayerTest.php

示例3: generateRewritesBasedOnCurrentRewrites

 /**
  * Generate permanent rewrites based on current rewrites
  *
  * @param int $storeId
  * @return array
  */
 protected function generateRewritesBasedOnCurrentRewrites($storeId)
 {
     $urls = [];
     foreach ($this->urlMatcher->findAllByFilter($this->createCurrentUrlRewritesFilter($storeId)) as $url) {
         $targetPath = null;
         if ($url->getRedirectType()) {
             $targetPath = str_replace($this->category->getOrigData('url_key'), $this->category->getData('url_key'), $url->getTargetPath());
             $redirectType = $url->getRedirectType();
         } elseif ($this->category->getData('save_rewrites_history')) {
             $targetPath = str_replace($this->category->getOrigData('url_key'), $this->category->getData('url_key'), $url->getRequestPath());
             $redirectType = OptionProvider::PERMANENT;
         }
         if ($targetPath && $url->getRequestPath() != $targetPath) {
             $urls[] = $this->createUrlRewrite($storeId, $url->getRequestPath(), $targetPath, $redirectType);
         }
     }
     return $urls;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:24,代码来源:CategoryUrlGenerator.php

示例4: generateProductUrlRewrites

 /**
  * Generate url rewrites for products assigned to category
  *
  * @param Category $category
  * @return array
  */
 public function generateProductUrlRewrites(Category $category)
 {
     $this->isSkippedProduct = [];
     $saveRewriteHistory = $category->getData('save_rewrites_history');
     $storeId = $category->getStoreId();
     $productUrls = [];
     if ($category->getAffectedProductIds()) {
         $this->isSkippedProduct = $category->getAffectedProductIds();
         $collection = $this->productCollectionFactory->create()->setStoreId($storeId)->addIdFilter($category->getAffectedProductIds())->addAttributeToSelect('name')->addAttributeToSelect('url_key')->addAttributeToSelect('url_path');
         foreach ($collection as $product) {
             $product->setStoreId($storeId);
             $product->setData('save_rewrites_history', $saveRewriteHistory);
             $productUrls = array_merge($productUrls, $this->productUrlRewriteGenerator->generate($product));
         }
     } else {
         $productUrls = array_merge($productUrls, $this->getCategoryProductsUrlRewrites($category, $storeId, $saveRewriteHistory));
     }
     foreach ($this->childrenCategoriesProvider->getChildren($category, true) as $childCategory) {
         $productUrls = array_merge($productUrls, $this->getCategoryProductsUrlRewrites($childCategory, $storeId, $saveRewriteHistory));
     }
     return $productUrls;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:28,代码来源:UrlRewriteHandler.php

示例5: getCategoryUrl

 /**
  * Retrieve category url
  *
  * @param ModelCategory $category
  * @return string
  */
 public function getCategoryUrl($category)
 {
     if ($category instanceof ModelCategory) {
         return $category->getUrl();
     }
     return $this->_categoryFactory->create()->setData($category->getData())->getUrl();
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:13,代码来源:Category.php

示例6: validateCategory

 /**
  * 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');
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:29,代码来源:CategoryRepository.php

示例7: getObject

 public function getObject(Category $category)
 {
     /** @var $productCollection Mage_Catalog_Model_Resource_Product_Collection */
     $productCollection = $category->getProductCollection();
     $productCollection = $productCollection->addMinimalPrice();
     $category->setProductCount($productCollection->getSize());
     $transport = new DataObject();
     $this->eventManager->dispatch('algolia_category_index_before', ['category' => $category, 'custom_data' => $transport]);
     $customData = $transport->getData();
     $storeId = $category->getStoreId();
     $category->getUrlInstance()->setStore($storeId);
     $path = '';
     foreach ($category->getPathIds() as $categoryId) {
         if ($path != '') {
             $path .= ' / ';
         }
         $path .= $this->getCategoryName($categoryId, $storeId);
     }
     $image_url = null;
     try {
         $image_url = $category->getImageUrl();
     } catch (\Exception $e) {
         /* no image, no default: not fatal */
     }
     $data = ['objectID' => $category->getId(), 'name' => $category->getName(), 'path' => $path, 'level' => $category->getLevel(), 'url' => $category->getUrl(), 'include_in_menu' => $category->getIncludeInMenu(), '_tags' => ['category'], 'popularity' => 1, 'product_count' => $category->getProductCount()];
     if (!empty($image_url)) {
         $data['image_url'] = $image_url;
     }
     foreach ($this->config->getCategoryAdditionalAttributes($storeId) as $attribute) {
         $value = $category->getData($attribute['attribute']);
         $attribute_resource = $category->getResource()->getAttribute($attribute['attribute']);
         if ($attribute_resource) {
             $value = $attribute_resource->getFrontend()->getValue($category);
         }
         if (isset($data[$attribute['attribute']])) {
             $value = $data[$attribute['attribute']];
         }
         if ($value) {
             $data[$attribute['attribute']] = $value;
         }
     }
     $data = array_merge($data, $customData);
     foreach ($data as &$data0) {
         $data0 = $this->try_cast($data0);
     }
     return $data;
 }
开发者ID:algolia,项目名称:algoliasearch-magento-2,代码行数:47,代码来源:CategoryHelper.php

示例8: getCategoryUrl

 /**
  * Get url for category data
  *
  * @param Category $category
  * @return string
  */
 public function getCategoryUrl($category)
 {
     if ($category instanceof Category) {
         $url = $category->getUrl();
     } else {
         $url = $this->_categoryInstance->setData($category->getData())->getUrl();
     }
     return $url;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:15,代码来源:Navigation.php

示例9: checkCategoryData

 /**
  * Check EAV and flat data
  *
  * @param \Magento\Catalog\Model\Category $category
  */
 protected function checkCategoryData(\Magento\Catalog\Model\Category $category)
 {
     foreach (self::$attributeCodes as $attributeCode) {
         $this->assertEquals(self::$attributeValues[$category->getId()][$attributeCode], $category->getData($attributeCode), "Data for {$category->getId()} attribute code [{$attributeCode}] is wrong");
     }
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:11,代码来源:FlatTest.php

示例10: createDataFromModel

 /**
  * @param Category $category
  * @return Metadata
  */
 public function createDataFromModel(Category $category)
 {
     $builder = $this->builder->populateWithArray($category->getData())->setCategoryId($category->getId())->setActive($category->getIsActive())->setChildren($category->getAllChildren(true));
     return $builder->create();
 }
开发者ID:aiesh,项目名称:magento2,代码行数:9,代码来源:Converter.php

示例11: getData

 /**
  * {@inheritdoc}
  */
 public function getData($key = '', $index = null)
 {
     $pluginInfo = $this->pluginList->getNext($this->subjectType, 'getData');
     if (!$pluginInfo) {
         return parent::getData($key, $index);
     } else {
         return $this->___callPlugins('getData', func_get_args(), $pluginInfo);
     }
 }
开发者ID:HaonanXu,项目名称:der-snack-backup,代码行数:12,代码来源:Interceptor.php


注:本文中的Magento\Catalog\Model\Category::getData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。