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


PHP Mage_Catalog_Model_Category::getParentIds方法代码示例

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


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

示例1: mergeCategories

 /**
  * @param bool $deleteSource
  *
  * @return bool
  */
 public function mergeCategories($deleteSource = false)
 {
     $this->_deleteSource = $deleteSource;
     try {
         // Check if both categories exist
         if (!$this->_source->getId() || !$this->_target->getId()) {
             return false;
         }
         $this->_moveProducts();
         $this->_moveChildrenCategories();
         // Just delete a category which is not parent of the target
         if ($this->_deleteSource && !in_array($this->_source->getId(), $this->_target->getParentIds())) {
             $this->_source->delete();
         }
         /** @var $index Mage_Index_Model_Process */
         $index = Mage::getModel('index/process')->load('catalog_category_product', 'indexer_code');
         if ($index->getId() && $index->getMode() == Mage_Index_Model_Process::MODE_REAL_TIME) {
             $index->reindexEverything();
         }
         Mage::dispatchEvent('mkleine_category_merge_finished', array('source_category' => $this->_source, 'target_category' => $this->_target));
         return true;
     } catch (Exception $e) {
         Mage::logException($e);
         return false;
     }
 }
开发者ID:hanicker,项目名称:magento-category-merge,代码行数:31,代码来源:Merge.php

示例2: testGetParentIds

 public function testGetParentIds()
 {
     $this->assertEquals(array(), $this->_model->getParentIds());
     $this->_model->unsetData();
     $this->_model->load(4);
     $this->assertContains(3, $this->_model->getParentIds());
     $this->assertNotContains(4, $this->_model->getParentIds());
 }
开发者ID:nemphys,项目名称:magento2,代码行数:8,代码来源:CategoryTreeTest.php

示例3: _collectTags

 /**
  * Should return list of tags to clean
  *
  * @param Mage_Catalog_Model_Category $object
  * @return string[]|string
  */
 protected function _collectTags($object)
 {
     $tags = array(self::TAG_PREFIX . $object->getId());
     if ($this->_isForUpdate) {
         foreach ($object->getParentIds() as $categoryId) {
             $tags[] = self::TAG_PREFIX . $categoryId;
         }
     }
     return $tags;
 }
开发者ID:jonesio,项目名称:EcomDev_Varnish,代码行数:16,代码来源:Category.php

示例4: changeParent

 /**
  * Move category to another parent node
  *
  * @param Mage_Catalog_Model_Category $category
  * @param Mage_Catalog_Model_Category $newParent
  * @param null|int $afterCategoryId
  * @return Mage_Catalog_Model_Resource_Category
  */
 public function changeParent(Mage_Catalog_Model_Category $category, Mage_Catalog_Model_Category $newParent, $afterCategoryId = null)
 {
     $childrenCount = $this->getChildrenCount($category->getId()) + 1;
     $table = $this->getEntityTable();
     $adapter = $this->_getWriteAdapter();
     $levelFiled = $adapter->quoteIdentifier('level');
     $pathField = $adapter->quoteIdentifier('path');
     /**
      * Decrease children count for all old category parent categories
      */
     $adapter->update($table, array('children_count' => new Zend_Db_Expr('children_count - ' . $childrenCount)), array('entity_id IN(?)' => $category->getParentIds()));
     /**
      * Increase children count for new category parents
      */
     $adapter->update($table, array('children_count' => new Zend_Db_Expr('children_count + ' . $childrenCount)), array('entity_id IN(?)' => $newParent->getPathIds()));
     $position = $this->_processPositions($category, $newParent, $afterCategoryId);
     $newPath = sprintf('%s/%s', $newParent->getPath(), $category->getId());
     $newLevel = $newParent->getLevel() + 1;
     $levelDisposition = $newLevel - $category->getLevel();
     /**
      * Update children nodes path
      */
     $adapter->update($table, array('path' => new Zend_Db_Expr('REPLACE(' . $pathField . ',' . $adapter->quote($category->getPath() . '/') . ', ' . $adapter->quote($newPath . '/') . ')'), 'level' => new Zend_Db_Expr($levelFiled . ' + ' . $levelDisposition)), array($pathField . ' LIKE ?' => $category->getPath() . '/%'));
     /**
      * Update moved category data
      */
     $data = array('path' => $newPath, 'level' => $newLevel, 'position' => $position, 'parent_id' => $newParent->getId());
     $adapter->update($table, $data, array('entity_id = ?' => $category->getId()));
     // Update category object to new data
     $category->addData($data);
     return $this;
 }
开发者ID:nemphys,项目名称:magento2,代码行数:40,代码来源:Category.php

示例5: getDesignUpdateData

 /**
  * Get design update data of parent categories
  *
  * @param Mage_Catalog_Model_Category $category
  * @return array
  */
 public function getDesignUpdateData($category)
 {
     $categories = array();
     $pathIds = array();
     foreach (array_reverse($category->getParentIds()) as $pathId) {
         if ($pathId == AO::app()->getStore()->getRootCategoryId()) {
             $pathIds[] = $pathId;
             break;
         }
         $pathIds[] = $pathId;
     }
     $select = $this->_getReadAdapter()->select()->from(array('main_table' => $this->getMainStoreTable($category->getStoreId())), array('main_table.entity_id', 'main_table.custom_design', 'main_table.custom_design_apply', 'main_table.custom_design_from', 'main_table.custom_design_to'))->where('main_table.entity_id IN (?)', $pathIds)->where('main_table.is_active = ?', '1')->order('main_table.path DESC');
     $result = $this->_getReadAdapter()->fetchAll($select);
     foreach ($result as $row) {
         $row['id'] = $row['entity_id'];
         $categories[$row['entity_id']] = AO::getModel('catalog/category')->setData($row);
     }
     return $categories;
 }
开发者ID:ronseigel,项目名称:agent-ohm,代码行数:25,代码来源:Resource_Eav_Mysql4_Category_Flat.php

示例6: changeParent

 /**
  * Move category to another parent node
  *
  * @param   Mage_Catalog_Model_Category $category
  * @param   Mage_Catalog_Model_Category $newParent
  * @param   null|int $afterCategoryId
  * @return  Mage_Catalog_Model_Resource_Eav_Mysql4_Category
  */
 public function changeParent(Mage_Catalog_Model_Category $category, Mage_Catalog_Model_Category $newParent, $afterCategoryId = null)
 {
     $childrenCount = $this->getChildrenCount($category->getId()) + 1;
     $table = $this->getEntityTable();
     $adapter = $this->_getWriteAdapter();
     $categoryId = $category->getId();
     /**
      * Decrease children count for all old category parent categories
      */
     $sql = "UPDATE {$table} SET children_count=children_count-{$childrenCount} WHERE entity_id IN(?)";
     $adapter->query($adapter->quoteInto($sql, $category->getParentIds()));
     /**
      * Increase children count for new category parents
      */
     $sql = "UPDATE {$table} SET children_count=children_count+{$childrenCount} WHERE entity_id IN(?)";
     $adapter->query($adapter->quoteInto($sql, $newParent->getPathIds()));
     $position = $this->_processPositions($category, $newParent, $afterCategoryId);
     $newPath = $newParent->getPath() . '/' . $category->getId();
     $newLevel = $newParent->getLevel() + 1;
     $levelDisposition = $newLevel - $category->getLevel();
     /**
      * Update children nodes path
      */
     $sql = "UPDATE {$table} SET\n            `path`  = REPLACE(`path`, '{$category->getPath()}/', '{$newPath}/'),\n            `level` = `level` + {$levelDisposition}\n            WHERE " . $adapter->quoteInto('path LIKE ?', $category->getPath() . '/%');
     $adapter->query($sql);
     /**
      * Update moved category data
      */
     $data = array('path' => $newPath, 'level' => $newLevel, 'position' => $position, 'parent_id' => $newParent->getId());
     $adapter->update($table, $data, $adapter->quoteInto('entity_id=?', $category->getId()));
     return $this;
 }
开发者ID:hunnybohara,项目名称:magento-chinese-localization,代码行数:40,代码来源:Category.php

示例7: _setIsActive

 /**
  * Fill the Field is_active in the given array
  * param $isRoot = false not needed here
  *
  * @param Mage_Catalog_Model_Category $category
  */
 protected function _setIsActive($category)
 {
     $catIds = Mage::getStoreConfig(Shopgate_Framework_Model_Config::XML_PATH_SHOPGATE_EXPORT_HIDDEN_CATEGORIES);
     $catIdsArray = array();
     if (!empty($cat_ids)) {
         $catIdsArray = explode(",", $catIds);
         foreach ($catIdsArray as &$catId) {
             $catId = trim($catId);
         }
     }
     $isActive = $category->getIsActive();
     if (in_array($category->getId(), $catIdsArray) || array_intersect($catIdsArray, $category->getParentIds())) {
         $isActive = 1;
     }
     if (Mage::getStoreConfig(Shopgate_Framework_Model_Config::XML_PATH_SHOPGATE_EXPORT_NAVIGATION_CATEGORIES_ONLY) && !$category->getIncludeInMenu()) {
         $isActive = 0;
     }
     $this->_defaultRow["is_active"] = $isActive;
 }
开发者ID:buttasg,项目名称:cowgirlk,代码行数:25,代码来源:Csv.php


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