How do I add new attributes to an attribute set using package upgrade?
Permalink
I'm trying to add a couple text fields and a couple select fields to an attribute set in a package I'm developing. I can't uninstall the package because we've already started adding content.
I've searched and I just can't find documentation on how to add those fields to a package using the package upgrade method.
Is this correct? Is there any documentation on this anywhere? I based this off the install for different attributes, the part I'm not sure about is $themeSet = AttributeSet::getByHandle('article');
Thank you!
I've searched and I just can't find documentation on how to add those fields to a package using the package upgrade method.
Is this correct? Is there any documentation on this anywhere? I based this off the install for different attributes, the part I'm not sure about is $themeSet = AttributeSet::getByHandle('article');
$select = AttributeType::getByHandle('select'); $themeSet = AttributeSet::getByHandle('article'); $akArticle6 = CollectionAttributeKey::add($select,array('akHandle'=>'vertical','akName'=>t('Vertical Market'),'akIsSearchableIndexed'=>true,'akIsSearchable'=>true),$this)->setAttributeSet($themeSet); $pageType = CollectionType::getByHandle('article'); $ak = CollectionAttributeKey::getByHandle('vertical'); $pageType->assignCollectionAttribute($ak); $akArticle6Option = SelectAttributeTypeOption::add($ak, 'All Verticals', 0, 0); $akArticle6Option = SelectAttributeTypeOption::add($ak, 'Food and Beverage', 0, 0);
Thank you!
Look in the controller in the c5 boilerplate package available in the marketplace. That should point you in the right direction.
Thanks, that gets me closer. Here's the upgrade portion from that controller:
What that doesn't particularly describe is how to add a new attribute to an existing attribute set. Do you have any insight?
public function upgrade() { // If you have an attribute type in your package that needs to // update it's database table, you will need to run this: // // $est = AttributeType::getByHandle('attribute_handle'); // $path = $est->getAttributeTypeFilePath(FILENAME_ATTRIBUTE_DB); // Package::installDB($path); parent::upgrade(); $pkg = Package::getByHandle($this->pkgHandle); $this->installAdditionalPageAttributes($pkg); }
What that doesn't particularly describe is how to add a new attribute to an existing attribute set. Do you have any insight?