Jump to content

Créer des attributs et valeurs automatiquement à l'installation du module


Recommended Posts

Tout est dit dans le titre, je cherche à créer des attributs et des valuers à la volé pour l'instant j'ai sa :

public function createAttributeValue($parentId)
    {
        $noDownloadable = new Attribute();
        $noDownloadable->name[0] = 'no';
        $noDownloadable->id_attribute_group = $parentId;
        $noDownloadable->add();

        $yesDownloadable = new Attribute();
        $yesDownloadable->name[0] = 'yes';
        $yesDownloadable->id_attribute_group = $parentId;
        $yesDownloadable->add();
    }

    public function createAttributeGroups()
    {
        $isDownloadable = new AttributeGroup();
        $isDownloadable->fields->name = 'isdownloadable';
        $isDownloadable->fields->public_name = 'isdownloadable';
        $isDownloadable->fields->group_type = 'test';
        $isDownloadable->fields->position = AttributeGroup::getHigherPosition() + 1;
        $isDownloadable->add();

        $this->createAttributeValue($isDownloadable->position);
    }

J'ai aussi testé sa:

public function createAttributeGroups()
    {
        $isDownloadable = new AttributeGroup();
        $isDownloadable->name[0] = 'isdownloadable';
        $isDownloadable->public_name[0] = 'isdownloadable';
        $isDownloadable->group_type = 'test';
        $isDownloadable->position = AttributeGroup::getHigherPosition() + 1;
        $isDownloadable->add();

        $this->createAttributeValue($isDownloadable->position);
    }

L'erreur qui m'est renvoyé par prestashop est la suivante : Property AttributeGroup->group_type is empty

 

je ne vois pas comment résoudre cette erreur.

 

Au secours ^^

Edited by kevingic (see edit history)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More