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


PHP Mage_Catalog_Model_Category::setPath方法代码示例

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


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

示例1: testGetPathIds

 public function testGetPathIds()
 {
     $this->assertEquals(array(''), $this->_model->getPathIds());
     $this->_model->setPathIds(array(1));
     $this->assertEquals(array(1), $this->_model->getPathIds());
     $this->_model->unsetData();
     $this->_model->setPath('1/2/3');
     $this->assertEquals(array(1, 2, 3), $this->_model->getPathIds());
 }
开发者ID:nemphys,项目名称:magento2,代码行数:9,代码来源:CategoryTreeTest.php

示例2: checkCategory

 private function checkCategory($parentId, $data)
 {
     //Eltern-Kategorie laden
     if (!isset($data) || isset($data) && !isset($data['SKID'])) {
         return null;
     }
     $stores = $this->getStores();
     $parentCategory = Mage::getModel('catalog/category')->getCollection()->addAttributeToSelect('scid')->addAttributeToSelect('name')->addAttributeToFilter('entity_id', array('eq' => $parentId))->getFirstItem();
     $children = Mage::getModel('catalog/category')->getCollection()->addAttributeToSelect('scid')->addAttributeToSelect('position')->addAttributeToSelect('name')->addAttributeToFilter('parent_id', array('eq' => $parentId));
     $isNew = true;
     $updateId = null;
     foreach ($children as $childCategory) {
         // alle Kategorien durchlaufen und schauen ob die übergebene dabei ist, falls nicht neu, falls ja nicht neu + updateId
         $scid = $childCategory->getScid();
         $position = $childCategory->getPosition();
         $name = $childCategory->getName();
         if ($scid == $data['SKID']) {
             $isNew = 0;
             $updateId = $childCategory->getId();
             break;
         }
     }
     if ($isNew) {
         //Kategorie muss angelegt werden
         $category = new Mage_Catalog_Model_Category();
         $category->setPath($parentCategory->getPath());
     }
     if ($updateId !== null) {
         $category = Mage::getModel('catalog/category')->load($updateId);
     }
     $isVisible = $this->isCategoryVisible($data['SKID']);
     if ($category) {
         $isActive = $data['active'] === "true" ? 1 : 0;
         $adminData = array('scid' => $data['SKID'], 'is_active' => $isActive, 'is_anchor' => 1, 'include_in_menu' => $isVisible);
         // deutsche Werte als admin-Werte setzen
         if (isset($data['name']) && isset($data['name']['de'])) {
             $adminData['name'] = $data['name']['de'];
             $adminData['url_key'] = $this->createSlug($data['name']['de']);
         }
         /*
         if(isset($data['description']) && isset($data['description']['de']))
         {
         				$adminData['description'] = $data['description']['de'];
         }
         
         if(isset($data['seo_text']) && isset($data['seo_text']['de']))
         {
         				$adminData['seo_text'] = $data['seo_text']['de'];
         }
         */
         if (isset($data['position'])) {
             $adminData['position'] = $data['position'] + 1;
         }
         $category->setStoreId(0);
         // 0 = admin ID
         $category->addData($adminData);
         $category->save();
         $category->setStoreId($stores['de']);
         // admin Werte für deutschen Store übernehmen
         $category->save();
         // Sichbarkeit im deutschen Store setzen
         foreach (['en', 'nl'] as $storeCode) {
             $storeData = [];
             //foreach (['name','description','seo_text'] as $key)
             foreach (['name'] as $key) {
                 if (isset($data[$key]) && isset($data[$key][$storeCode])) {
                     $storeData[$key] = $data[$key][$storeCode];
                 }
             }
             if (isset($data['name'][$storeCode])) {
                 $storeData['url_key'] = $this->createSlug($data['name'][$storeCode]);
             }
             $category->setStoreId($stores[$storeCode]);
             $category->addData($storeData);
             $category->setIncludeInMenu($isVisible);
             $category->save();
         }
         $newId = $category->getId();
         unset($category);
     }
     return $newId;
 }
开发者ID:jronatay,项目名称:ultimo-magento-jron,代码行数:82,代码来源:mageSOAPAdvanced.php

示例3: createCategory

 public function createCategory()
 {
     $catId = $this->getCategoryIdByName($this->categoryName);
     if ($catId) {
         return $catId;
     }
     $parentId = Mage::app()->getStore($this->storeId)->getRootCategoryId();
     $category = new Mage_Catalog_Model_Category();
     $category->setName($this->categoryName);
     $category->setUrlKey('contact-lenses');
     $category->setIsActive(1);
     $category->setDisplayMode('PRODUCTS');
     $category->setIsAnchor(0);
     $parentCategory = Mage::getModel('catalog/category')->load($parentId);
     $category->setPath($parentCategory->getPath());
     $category->save();
     //unset($category);
     return $category->getId();
 }
开发者ID:CherylMuniz,项目名称:fashion,代码行数:19,代码来源:lens.php

示例4:

 function create_category($parentId, $name, $url)
 {
     $category = new Mage_Catalog_Model_Category();
     $category->setName($name);
     $category->setUrlKey($url);
     $category->setIsActive(1);
     $category->setDisplayMode('PRODUCTS');
     $category->setIsAnchor(0);
     $parentCategory = Mage::getModel('catalog/category')->load($parentId);
     $category->setPath($parentCategory->getPath());
     $category->save();
     return $category->getId();
 }
开发者ID:xiaoguizhidao,项目名称:ortodon,代码行数:13,代码来源:WebController.php

示例5: array

<?php

ini_set("memory_limit", "1000M");
require_once "/home/www/demo/app/Mage.php";
umask(0);
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
/* supply parent id */
$parentId = '258';
//$name = 'Mont Blank';
$names = array('Burberry', 'Swarovski', 'Bvlgari', 'Tom Ford', 'Carrera', 'Oakley', 'Chanel', 'Oliver Peoples', 'Dior', 'Paul Smith', 'D&G', 'Polo Ralf Lauren', 'Dsquared', 'Prada', 'Diesel', 'Gucci', 'Ray Ban', 'Tiffany', 'Hugo Boss');
foreach ($names as $name) {
    $category = new Mage_Catalog_Model_Category();
    $category->setName($name);
    $category->setIsActive(1);
    $category->setDisplayMode('PAGE');
    $category->setIsAnchor(1);
    $category->setIncludeInMenu(0);
    $parentCategory = Mage::getModel('catalog/category')->load($parentId);
    $category->setPath($parentCategory->getPath());
    try {
        $category->save();
        echo $category->getName() . ' - ' . $category->getId() . "\n";
    } catch (Exception $e) {
        echo $e->getMessage();
    }
    unset($category);
}
开发者ID:CherylMuniz,项目名称:fashion,代码行数:27,代码来源:setCategory.php

示例6: createCategory

 public function createCategory($object)
 {
     $collection = Mage::getModel('catalog/category')->getCollection()->clear();
     $category = new Mage_Catalog_Model_Category();
     $category->setEntityTypeId($this->entityTypeId);
     $category->setAttributeSetId($this->attributeSetId);
     if (!empty($object['custom_apply_to_products'])) {
         $category->setCustomApplyToProducts($object['custom_apply_to_products']);
     }
     if (!empty($object['custom_design'])) {
         $category->setCustomDesign($object['custom_design']);
     }
     if (!empty($object['custom_design_from'])) {
         $category->setCustomDesignFrom($object['custom_design_from']);
     }
     if (!empty($object['custom_design_to'])) {
         $category->setCustomDesignTo($object['custom_design_to']);
     }
     if (!empty($object['custom_layout_update'])) {
         $category->setCustomLayoutUpdate($object['custom_layout_update']);
     }
     if (!empty($object['custom_use_parent_settings'])) {
         $category->setCustomUseParentSettings($object['custom_use_parent_settings']);
     }
     $category->setAvailablesortBy($object['available_sort_by']);
     $category->setParentId(0);
     $category->setCreatedAt($object['created_at']);
     $category->setUpdatedAt($object['updated_at']);
     $category->setPosition((int) $object['position']);
     $category->setChildrenCount($object['children_count']);
     $category->setDescription($object['description']);
     $category->setDisplayMode($object['display_mode']);
     $category->setDefaultSortBy($object['default_sort_by']);
     $category->setFilterPriceRange($object['filter_price_range']);
     $category->setImage($object['image']);
     $category->setIncludeInMenu($object['include_in_menu']);
     $category->setIsActive($object['is_active']);
     $category->setIsAnchor($object['is_anchor']);
     $category->setLandingPage($object['landing_page']);
     $category->setLevel($object['level']);
     $category->setMetaTitle($object['meta_title']);
     $category->setMetaKeywords($object['meta_keywords']);
     $category->setMetaDescription($object['meta_description']);
     $category->setName($object['name']);
     $category->setPageLayout($object['page_layout']);
     if (!empty($object['path'])) {
         $category->setPath($object['path']);
     }
     if (!empty($object['path_in_store'])) {
         $category->setPathInStore($object['path_in_store']);
     }
     $category->setPosition((int) $object['position']);
     $category->setThumbnail((int) $object['thumbnail']);
     $category->setUrlKey($object['url_key']);
     $category->setUrlPath($object['url_path']);
     try {
         $category->save();
         $category->load();
         // must do it, because of position set wrong for first saving. magento bug?
         $category->setPosition((int) $object['position']);
         $category->save();
     } catch (Exception $e) {
         zend_debug::dump($e);
         return;
     }
     return $category->getId();
 }
开发者ID:CherylMuniz,项目名称:fashion,代码行数:67,代码来源:5catsimp.php


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