How to get custom attributes in Opencart?

I defined some user attributes and assigned them to products through the Opencart control panel . I am trying to get these attributes when placing an order in order to adjust some shipping costs.

I am currently working on a file catalog/model/shipping/ups.phpin getQuote. I get close to this:

print_r($this->cart->getProducts());

Which gives me the following product data:

Array
(
    [59] => Array
        (
            [key] => 59
            [product_id] => 59
            [name] => My Product Name 
            [model] => ABC
            [shipping] => 1
            [image] => data/myproduct.jpg
            [option] => Array
                (
                )

            [download] => Array
                (
                )

            [quantity] => 1
            [minimum] => 1
            [subtract] => 1
            [stock] => 1
            [price] => 29.99
            [total] => 29.99
            [reward] => 0
            [points] => 0
            [tax_class_id] => 0
            [weight] => 3.75
            [weight_class_id] => 5
            [length] => 0.00
            [width] => 0.00
            [height] => 0.00
            [length_class_id] => 3
        )

)

However, no custom attributes are returned. I am sure there is a good way to pass the product identifier to the attribute retrieval function, but I cannot find it. Opencart docs aren't needed for development a bit, and Google is out of luck.

grep , , , -: (.

, - , Opencart. .

, > " ". , , . . . - " ". @Cleverbot? , db-, , theres ?

opencart product attributes

+5
2

product_id

$this->load->model('catalog/product');

$attributes = $this->model_catalog_product->getProductAttributes(59); 

print_r($attributes);

Array
(
    [0] => Array
        (
            [attribute_group_id] => 9
            [name] => Shipping Fields
            [attribute] => Array
                (
                    [0] => Array
                        (
                            [attribute_id] => 16
                            [name] => Shipping Box Type
                            [text] => SM2
                        )

                )

        )

)

, , , , :

$this->load->model('catalog/product');

$cart_products = $this->cart->getProducts();

// get attributes for each product in the cart
foreach($cart_products as $product) {
    $attributes = $this->model_catalog_product->getProductAttributes($product['product_id']);
    print_r($attributes);
}
+6

Opencart. > > , , . " ".

> > > " " " ".

> .

, , , . . "" /view/ * your_theme */products/products.tpl tpl, /, .

+2

All Articles