Please help us to make AbanteCart Ideal Open Source Ecommerce Solution for everyone.

Support AbanteCart eCommerce

Author Topic: Add Global Attributes  (Read 5994 times)

Offline ABolm

  • Newbie
  • *
  • Posts: 4
  • Karma: +1/-0
    • View Profile
Add Global Attributes
« on: May 04, 2017, 05:54:03 AM »
Hi,
I'm new to this forum, my name is Andreas.

I've bought a couple of days ago the ExtraTabs extension from the marketplace for use in one of my own extensions.

Now if have the problem to add global attributes via API, the API is -without a doubt- some fine peace of work, but sometimes the "right use" of hooks and sub-controllers thrills me. As there is little or no documentation in source code for specific intricate controllers.

My goal is to setup global attributes and write data into the "global_attibute" table and it's affiliated "value" and "description" tables, from one of my extensions.

So the question is, how do I write the proper php-code for the task mentioned.

I did some Investigations, build a SQL EER chart, but I really don't figure it out on the PHP part.


PS: I must excuse for the somewhat poor EER image
      quality, the maximum individual upload size is
      restricted to 128KB per file. I had to compress
      the jpeg by reducing the image quality.



Offline abolabo

  • core-developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 2046
  • Karma: +318/-13
  • web for all, all for web!
    • View Profile
    • AbanteCart
Re: Add Global Attributes
« Reply #1 on: May 04, 2017, 06:41:38 AM »
Hello.
Unfortunately, AbanteCart does not allow to manage attributes via admin-side API.

I guess you should to create your own api-controller inside your extension to do this.
Please follow these common steps:
1. Create new api-controller inside /public_html/extensions/your_extension_name/admin/controller/api/catalog/attributes.php
2. add route for this into main.php file of your extension
3. Use some of api-controllers from core (for ex. public_html/admin/controller/api/index/login.php etc) as example
4. To manipulate attributes use core/lib/attribute_manager.php library. You can look into /public_html/admin/controller/pages/catalog/attribute.php line 155 for example
“No one is useless in this world who lightens the burdens of another.”
― Charles Dickens

Offline ABolm

  • Newbie
  • *
  • Posts: 4
  • Karma: +1/-0
    • View Profile
Re: Add Global Attributes
« Reply #2 on: May 04, 2017, 08:28:22 AM »
Thanks for the fast reply,

I need to clear some logic questions went into my mind while reading your answer. Usually AbanteCart resource locations and resource names, are sometimes heavily restricted.
Therefore my fist question

1. Create new api-controller inside /public_html/extensions/your_extension_name/admin/controller/api/catalog/attributes.php

Is the .../api/catalog/attributes.php, or any part of it, restricted or just a matter of main.php registration. Exempt the controller naming convention of course, in this case "ControllerApiCatalogAttributes" I think.

3. Use some of api-controllers from core (for ex. public_html/admin/controller/api/index/login.php etc) as example

Can I put the statement to conclusion, any controller necessary to fulfill my internal process logic.

Offline abolabo

  • core-developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 2046
  • Karma: +318/-13
  • web for all, all for web!
    • View Profile
    • AbanteCart
Re: Add Global Attributes
« Reply #3 on: May 04, 2017, 10:25:40 AM »

I need to clear some logic questions went into my mind while reading your answer. Usually AbanteCart resource locations and resource names, are sometimes heavily restricted.
Therefore my fist question

1. Create new api-controller inside /public_html/extensions/your_extension_name/admin/controller/api/catalog/attributes.php

Is the .../api/catalog/attributes.php, or any part of it, restricted or just a matter of main.php registration. Exempt the controller naming convention of course, in this case "ControllerApiCatalogAttributes" I think.

You can use your own route here. No restrictions. Just add  'api/your/route.php' into your main.php and set name of class ControllerAPIYourRoute

3. Use some of api-controllers from core (for ex. public_html/admin/controller/api/index/login.php etc) as example

Can I put the statement to conclusion, any controller necessary to fulfill my internal process logic.

i just wrote this to suggest example for creating your own controller
“No one is useless in this world who lightens the burdens of another.”
― Charles Dickens

Offline ABolm

  • Newbie
  • *
  • Posts: 4
  • Karma: +1/-0
    • View Profile
Re: Add Global Attributes
« Reply #4 on: May 04, 2017, 11:07:50 AM »
Is this a yes or a no  ;D

 

Powered by SMFPacks Social Login Mod