Source of file GoogleBaseCategory.php
Size: 1,114 Bytes - Last Modified: 2021-12-23T10:55:57+00:00
/var/www/docs.ssmods.com/process/src/code/GoogleBaseCategory.php
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 | <?php /** * Extends: ProductCategory * Extension to add GoogleBaseCategory db field and CMS fields. * * * @author Tyler Kidd <tyler@adaircreative.com> * @date 04.23.2014 */ class GoogleBaseCategory extends SiteTreeExtension { static $db = array( 'GoogleBaseCategory' => 'Varchar(255)' ); public function updateCMSFields(FieldList $fields) { $fields->addFieldtoTab('Root.GoogleBase', TextField::create('GoogleBaseCategory','Google Base Category')); } /** * Get a recursive list of Product Categories where parents are ProductCategories * @return array of categories */ public function GoogleBaseCategoryList(){ $categoryList = array(); $parent = $this->owner->Parent(); if ($parent->ClassName == 'ProductCategory') { $parentList = $parent->GoogleBaseCategoryList(); if (empty($parentList)) { $categoryList[] = $parent->GoogleBaseCategory; } else { $categoryList = array_merge($categoryList, $parentList); } } if($this->owner->GoogleBaseCategory){ $categoryList[] = $this->owner->GoogleBaseCategory; } return $categoryList; } } |