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


PHP ProductCategory::get方法代码示例

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


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

示例1: handleRequest

 public function handleRequest(SS_HTTPRequest $request, DataModel $model)
 {
     $this->pushCurrent();
     $this->urlParams = $request->allParams();
     $this->request = $request;
     $this->response = new SS_HTTPResponse();
     $this->setDataModel($model);
     $urlsegment = $request->param('URLSegment');
     $this->extend('onBeforeInit');
     $this->init();
     $this->extend('onAfterInit');
     // First check products against URL segment
     if ($product = Product::get()->filter(array('URLSegment' => $urlsegment, 'Disabled' => 0))->first()) {
         $controller = Catalogue_Controller::create($product);
     } elseif ($category = ProductCategory::get()->filter('URLSegment', $urlsegment)->first()) {
         $controller = Catalogue_Controller::create($category);
     } else {
         // If CMS is installed
         if (class_exists('ModelAsController')) {
             $controller = ModelAsController::create();
         }
     }
     $result = $controller->handleRequest($request, $model);
     $this->popCurrent();
     return $result;
 }
开发者ID:helpfulrobot,项目名称:i-lateral-silverstripe-commerce,代码行数:26,代码来源:CommerceURLController.php

示例2: GroupsMenu

 /**
  * Recursively generate a product menu, starting from the topmost category.
  *
  * @return DataList
  */
 public function GroupsMenu()
 {
     if ($this->Parent() instanceof ProductCategory) {
         return $this->Parent()->GroupsMenu();
     }
     return ProductCategory::get()->filter("ParentID", $this->ID);
 }
开发者ID:burnbright,项目名称:silverstripe-shop,代码行数:12,代码来源:ProductCategory.php

示例3: getDefaultSearchContext

 public function getDefaultSearchContext()
 {
     $context = parent::getDefaultSearchContext();
     $fields = $context->getFields();
     $fields->push(CheckboxField::create("HasBeenUsed"));
     //add date range filtering
     $fields->push(ToggleCompositeField::create("StartDate", "Start Date", array(DateField::create("q[StartDateFrom]", "From")->setConfig('showcalendar', true), DateField::create("q[StartDateTo]", "To")->setConfig('showcalendar', true))));
     $fields->push(ToggleCompositeField::create("EndDate", "End Date", array(DateField::create("q[EndDateFrom]", "From")->setConfig('showcalendar', true), DateField::create("q[EndDateTo]", "To")->setConfig('showcalendar', true))));
     //must be enabled in config, because some sites may have many products = slow load time, or memory maxes out
     //future solution is using an ajaxified field
     if (self::config()->filter_by_product) {
         $fields->push(ListboxField::create("Products", "Products", Product::get()->map()->toArray())->setMultiple(true));
     }
     if (self::config()->filter_by_category) {
         $fields->push(ListboxField::create("Categories", "Categories", ProductCategory::get()->map()->toArray())->setMultiple(true));
     }
     if ($field = $fields->fieldByName("Code")) {
         $field->setDescription("This can be a partial match.");
     }
     //get the array, to maniplulate name, and fullname seperately
     $filters = $context->getFilters();
     $filters['StartDateFrom'] = GreaterThanOrEqualFilter::create('StartDate');
     $filters['StartDateTo'] = LessThanOrEqualFilter::create('StartDate');
     $filters['EndDateFrom'] = GreaterThanOrEqualFilter::create('EndDate');
     $filters['EndDateTo'] = LessThanOrEqualFilter::create('EndDate');
     $context->setFilters($filters);
     return $context;
 }
开发者ID:helpfulrobot,项目名称:silvershop-discounts,代码行数:28,代码来源:Discount.php

示例4: __construct

 public function __construct($controller, $name)
 {
     $product = new Product();
     $title = new TextField('Title', _t('Product.PAGETITLE', 'Product Title'));
     $urlSegment = new TextField('URLSegment', 'URL Segment');
     $menuTitle = new TextField('MenuTitle', 'Navigation Title');
     $sku = TextField::create('InternalItemID', _t('Product.CODE', 'Product Code/SKU'), '', 30);
     $categories = DropdownField::create('ParentID', _t("Product.CATEGORY", "Category"), $product->categoryoptions())->setDescription(_t("Product.CATEGORYDESCRIPTION", "This is the parent page or default category."));
     $otherCategories = ListBoxField::create('ProductCategories', _t("Product.ADDITIONALCATEGORIES", "Additional Categories"), ProductCategory::get()->filter("ID:not", $product->getAncestors()->map('ID', 'ID'))->map('ID', 'NestedTitle')->toArray())->setMultiple(true);
     $model = TextField::create('Model', _t('Product.MODEL', 'Model'), '', 30);
     $featured = CheckboxField::create('Featured', _t('Product.FEATURED', 'Featured Product'));
     $allow_purchase = CheckboxField::create('AllowPurchase', _t('Product.ALLOWPURCHASE', 'Allow product to be purchased'), 1, 'Content');
     $price = TextField::create('BasePrice', _t('Product.PRICE', 'Price'))->setDescription(_t('Product.PRICEDESC', "Base price to sell this product at."))->setMaxLength(12);
     $image = UploadField::create('Image', _t('Product.IMAGE', 'Product Image'));
     $content = new HtmlEditorField('Content', 'Content');
     $fields = new FieldList();
     $fields->add($title);
     //$fields->add($urlSegment);
     //$fields->add($menuTitle);
     //$fields->add($sku);
     $fields->add($categories);
     //$fields->add($otherCategories);
     $fields->add($model);
     $fields->add($featured);
     $fields->add($allow_purchase);
     $fields->add($price);
     $fields->add($image);
     $fields->add($content);
     //$fields = $product->getFrontEndFields();
     $actions = new FieldList(new FormAction('submit', _t("ChefProductForm.ADDPRODUCT", 'Add product')));
     $requiredFields = new RequiredFields(array('Title', 'Model', 'Price'));
     parent::__construct($controller, $name, $fields, $actions, $requiredFields);
 }
开发者ID:8secs,项目名称:cocina,代码行数:33,代码来源:ChefProductForm.php

示例5: getContinueLink

 public function getContinueLink()
 {
     $maincategory = ProductCategory::get()->sort(array("ParentID" => "ASC", "ID" => "ASC"))->first();
     if ($maincategory) {
         return $maincategory->Link();
     }
     return Director::baseURL();
 }
开发者ID:helpfulrobot,项目名称:silvershop-core,代码行数:8,代码来源:ViewableCart.php

示例6: getCategoryChildren

 public function getCategoryChildren()
 {
     $category = ProductCategory::get()->filter('ID', $this->CategoryID)->first();
     if ($category && $category->Children()->exists()) {
         return $category->Children();
     } else {
         return $category->Products();
     }
 }
开发者ID:helpfulrobot,项目名称:i-lateral-silverstripe-commerce,代码行数:9,代码来源:Catalog.php

示例7: getCMSFields

 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     if ($checkouts = CheckoutPage::get()) {
         $fields->addFieldToTab('Root.Links', DropdownField::create('CheckoutPageID', _t('CartPage.has_one_CheckoutPage', 'Checkout Page'), $checkouts->map("ID", "Title")));
     }
     if ($pgroups = ProductCategory::get()) {
         $fields->addFieldToTab('Root.Links', DropdownField::create('ContinuePageID', _t('CartPage.has_one_ContinuePage', 'Continue Product Group Page'), $pgroups->map("ID", "Title")));
     }
     return $fields;
 }
开发者ID:NobrainerWeb,项目名称:silverstripe-shop,代码行数:11,代码来源:CartPage.php

示例8: get_current_category

 /**
  * Find the current category via its URL
  *
  * @return ProductCategory
  *
  */
 public static function get_current_category()
 {
     $segment = Controller::curr()->request->param('URLSegment');
     $return = null;
     if ($segment) {
         $return = ProductCategory::get()->filter('URLSegment', $segment)->first();
     }
     if (!$return) {
         $return = ProductCategory::create();
     }
     return $return;
 }
开发者ID:helpfulrobot,项目名称:i-lateral-silverstripe-commerce,代码行数:18,代码来源:Catalogue_Controller.php

示例9: getContinueLink

 public function getContinueLink()
 {
     if ($cartPage = CartPage::get()->first()) {
         if ($cartPage->ContinuePageID) {
             return $cartPage->ContinuePage()->Link();
         }
     }
     $maincategory = ProductCategory::get()->sort(array("ParentID" => "ASC", "ID" => "ASC"))->first();
     if ($maincategory) {
         return $maincategory->Link();
     }
     return Director::baseURL();
 }
开发者ID:burnbright,项目名称:silverstripe-shop,代码行数:13,代码来源:ViewableCart.php

示例10: updateCMSFields

 public function updateCMSFields(FieldList $fields)
 {
     // set TabSet names to avoid spaces from camel case
     $fields->addFieldToTab('Root', new TabSet('FoxyStripe', 'FoxyStripe'));
     // settings tab
     $fields->addFieldsToTab('Root.FoxyStripe.Settings', array(HeaderField::create('StoreDetails', _t('FoxyStripeSiteConfig.StoreDetails', 'Store Settings'), 3), LiteralField::create('DetailsIntro', _t('FoxyStripeSiteConfig.DetailsIntro', '<p>Maps to data in your <a href="https://admin.foxycart.com/admin.php?ThisAction=EditStore" target="_blank">FoxyCart store settings</a>.')), TextField::create('StoreName')->setTitle(_t('FoxyStripeSiteConfig.StoreName', 'Store Sub Domain'))->setDescription(_t('FoxyStripeSiteConfig.StoreNameDescription', 'the sub domain for your FoxyCart store')), HeaderField::create('AdvanceHeader', _t('FoxyStripeSiteConfig.AdvancedHeader', 'Advanced Settings'), 3), LiteralField::create('AdvancedIntro', _t('FoxyStripeSiteConfig.AdvancedIntro', '<p>Maps to data in your <a href="https://admin.foxycart.com/admin.php?ThisAction=EditAdvancedFeatures" target="_blank">FoxyCart advanced store settings</a>.</p>')), ReadonlyField::create('DataFeedLink', _t('FoxyStripeSiteConfig.DataFeedLink', 'FoxyCart DataFeed URL'), self::getDataFeedLink())->setDescription(_t('FoxyStripeSiteConfig.DataFeedLinkDescription', 'copy/paste to FoxyCart')), CheckboxField::create('CartValidation')->setTitle(_t('FoxyStripeSiteConfig.CartValidation', 'Enable Cart Validation'))->setDescription(_t('FoxyStripeSiteConfig.CartValidationDescription', 'You must <a href="https://admin.foxycart.com/admin.php?ThisAction=EditAdvancedFeatures#use_cart_validation" target="_blank">enable cart validation</a> in the FoxyCart admin.')), ReadonlyField::create('StoreKey')->setTitle(_t('FoxyStripeSiteConfig.StoreKey', 'FoxyCart API Key'))->setDescription(_t('FoxyStripeSiteConfig.StoreKeyDescription', 'copy/paste to FoxyCart')), ReadonlyField::create('SSOLink', _t('FoxyStripeSiteConfig.SSOLink', 'Single Sign On URL'), self::getSSOLink())->setDescription(_t('FoxyStripeSiteConfig.SSOLinkDescription', 'copy/paste to FoxyCart'))));
     // configuration warning
     if (FoxyCart::store_name_warning() !== null) {
         $fields->insertBefore(LiteralField::create("StoreSubDomainHeaderWarning", _t('FoxyStripeSiteConfig.StoreSubDomainHeadingWarning', "<p class=\"message error\">Store sub-domain must be entered in the <a href=\"/admin/settings/\">site settings</a></p>")), 'StoreDetails');
     }
     // products tab
     $fields->addFieldsToTab('Root.FoxyStripe.Products', array(HeaderField::create('ProductHeader', _t('FoxyStripeSiteConfig.ProductHeader', 'Products'), 3), CheckboxField::create('MultiGroup')->setTitle(_t('FoxyStripeSiteConfig.MultiGroup', 'Multiple Groups'))->setDescription(_t('FoxyStripeSiteConfig.MultiGroupDescription', 'Allows products to be shown in multiple Product Groups')), HeaderField::create('ProductGroupHD', _t('FoxyStripeSiteConfig.ProductGroupHD', 'Product Groups'), 3), NumericField::create('ProductLimit')->setTitle(_t('FoxyStripeSiteConfig.ProductLimit', 'Products per Page'))->setDescription(_t('FoxyStripeSiteConfig.ProductLimitDescription', 'Number of Products to show per page on a Product Group')), HeaderField::create('ProductQuantityHD', _t('FoxyStripeSiteConfig.ProductQuantityHD', 'Product Form Max Quantity'), 3), NumericField::create('MaxQuantity')->setTitle(_t('FoxyStripeSiteConfig.MaxQuantity', 'Max Quantity'))->setDescription(_t('FoxyStripeSiteConfig.MaxQuantityDescription', 'Sets max quantity for product form dropdown (add to cart form - default 10)'))));
     // categories tab
     $fields->addFieldsToTab('Root.FoxyStripe.Categories', array(HeaderField::create('CategoryHD', _t('FoxyStripeSiteConfig.CategoryHD', 'FoxyStripe Categories'), 3), LiteralField::create('CategoryDescrip', _t('FoxyStripeSiteConfig.CategoryDescrip', '<p>FoxyCart Categories offer a way to give products additional behaviors that cannot be accomplished by product options alone, including category specific coupon codes, shipping and handling fees, and email receipts. <a href="https://wiki.foxycart.com/v/2.0/categories" target="_blank">Learn More</a></p><p>Categories you\'ve created in FoxyStripe must also be created in your <a href="https://admin.foxycart.com/admin.php?ThisAction=ManageProductCategories" target="_blank">FoxyCart Categories</a> admin panel.</p>')), GridField::create('ProductCategory', _t('FoxyStripeSiteConfig.ProductCategory', 'FoxyCart Categories'), ProductCategory::get(), GridFieldConfig_RecordEditor::create())));
     // option groups tab
     $fields->addFieldsToTab('Root.FoxyStripe.Groups', array(HeaderField::create('OptionGroupsHead', _t('FoxyStripeSiteConfig', 'Product Option Groups'), 3), LiteralField::create('OptionGroupsDescrip', _t('FoxyStripeSiteConfig.OptionGroupsDescrip', '<p>Product Option Groups allow you to name a set of product options.</p>')), GridField::create('OptionGroup', _t('FoxyStripeSiteConfig.OptionGroup', 'Product Option Groups'), OptionGroup::get(), GridFieldConfig_RecordEditor::create())));
 }
开发者ID:helpfulrobot,项目名称:dynamic-foxystripe,代码行数:17,代码来源:FoxyStripeSiteConfig.php

示例11: run

 public function run($request)
 {
     $products = 0;
     $categories = 0;
     // First load all products
     $items = Product::get();
     foreach ($items as $item) {
         // Just write product, on before write should deal with the rest
         $item->write();
         $products++;
     }
     // Then all categories
     $items = ProductCategory::get();
     foreach ($items as $item) {
         // Just write category, on before write should deal with the rest
         $item->write();
         $categories++;
     }
     echo "Wrote {$products} products and {$categories} categories.\n";
 }
开发者ID:helpfulrobot,项目名称:i-lateral-silverstripe-commerce,代码行数:20,代码来源:CommerceWriteItemsTask.php

示例12: get_category_hierarchy

 /**
  * Returns an array of categories suitable for a dropdown menu
  * TODO: cache this
  *
  * @param int $parentID [optional]
  * @param string $prefix [optional]
  * @param int $maxDepth [optional]
  * @return array
  * @static
  */
 public static function get_category_hierarchy($parentID = 0, $prefix = '', $maxDepth = 999)
 {
     $out = array();
     $cats = ProductCategory::get()->filter(array('ParentID' => $parentID, 'ShowInMenus' => 1))->sort('Sort');
     // If there is a single parent category (usually "Products" or something), we
     // probably don't want that in the hierarchy.
     if ($parentID == 0 && $cats->count() == 1) {
         return self::get_category_hierarchy($cats->first()->ID, $prefix, $maxDepth);
     }
     foreach ($cats as $cat) {
         $out[$cat->ID] = $prefix . $cat->Title;
         if ($maxDepth > 1) {
             $out += self::get_category_hierarchy($cat->ID, $prefix . $cat->Title . ' > ', $maxDepth - 1);
         }
     }
     return $out;
 }
开发者ID:hex0id,项目名称:silverstripe-shop-search,代码行数:27,代码来源:ShopSearch.php

示例13: array

// config
$manufacturerIds = [23, 75, 97];
$categoryIds = [166];
// validation
$manufacturers = array();
foreach ($manufacturerIds as $id) {
    if (($i = Manufacturer::get($id)) instanceof Manufacturer) {
        $manufacturers[] = $i;
        echo 'try to disable all product with manufactuer "' . $i->getName() . '"(' . $i->getId() . ')' . "\n";
    } else {
        throw new Exception('Invalid manufactuer id "' . $id . '" passed in');
    }
}
$manufacturerIds = array_map(create_function('$a', 'return $a->getId();'), $manufacturers);
foreach ($categoryIds as $id) {
    if (($i = ProductCategory::get($id)) instanceof ProductCategory) {
        $categories[] = $i;
        echo 'try to disable all product with category "' . $i->getName() . '"(' . $i->getId() . ')' . "\n";
    } else {
        throw new Exception('Invalid category id "' . $id . '" passed in');
    }
}
$categoryIds = array_map(create_function('$a', 'return $a->getId();'), $categories);
// run
$products = Product::getProducts('', '', array(), $manufacturerIds, $categoryIds);
$count = 0;
echo 'found total ' . count($products) . ' products' . "\n";
foreach ($products as $product) {
    if ($product->getStockOnHand() == 0 && $product->getStockOnOrder() == 0 && $product->getStockOnPO() == 0 && $product->getStockInParts() == 0) {
        $sku = $product->getSku();
        disableProduct($sku);
开发者ID:larryu,项目名称:magento-b2b,代码行数:31,代码来源:DisableMageProducts07Aug15.php

示例14: getCommerceCategories

 /**
  * Gets a list of all ProductCategories
  *
  * @param Parent the ID of a parent cetegory
  * @return DataList
  */
 public function getCommerceCategories($ParentID = 0)
 {
     return ProductCategory::get()->filter("ParentID", $ParentID);
 }
开发者ID:helpfulrobot,项目名称:i-lateral-silverstripe-commerce,代码行数:10,代码来源:Ext_Commerce_Controller.php

示例15: testProductCategoryDeletion

 function testProductCategoryDeletion()
 {
     $this->logInWithPermission('Product_CANCRUD');
     $category = $this->objFromFixture('ProductCategory', 'default');
     $category->write();
     $this->assertFalse($category->canDelete());
     $category2 = $this->objFromFixture('ProductCategory', 'apparel');
     $category2->write();
     $category2ID = $category2->ID;
     $this->assertTrue($category2->canDelete());
     $this->logOut();
     $this->logInWithPermission('ADMIN');
     $this->assertFalse($category->canDelete());
     $this->assertTrue($category2->canDelete());
     $this->logOut();
     $this->logInWithPermission('Product_CANCRUD');
     $category2->delete();
     $this->assertFalse(in_array($category2ID, ProductCategory::get()->column('ID')));
 }
开发者ID:helpfulrobot,项目名称:dynamic-foxystripe,代码行数:19,代码来源:ProductPageTest.php


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