Plugin Directory

Changeset 3130058


Ignore:
Timestamp:
08/02/2024 01:23:29 PM (20 months ago)
Author:
weboneco
Message:

add product description and attributes in api get product by id response

File:
1 edited

Legend:

Unmodified
Added
Removed
  • gholab/trunk/src/Helpers/Helpers.php

    r3088300 r3130058  
    134134        }
    135135
     136        $productData['description'] = $product->get_description();
     137
     138        $productData['attributes'] = [];
     139        foreach ($product->get_attributes() as $attr) {
     140            $productData['attributes'][] = [
     141                'name'    => $attr->get_name(),
     142                'options' => $attr->get_options()
     143            ];
     144        }
     145
    136146        return [
    137147            'category_name'              => implode(' | ', $categoryNames),
     
    139149            'product_name'               => $productData['name'],
    140150            'product_gallery'            => self::getProductGalleryImages($productData['gallery_image_ids']),
    141             'product_specs'              => self::getProductsSpecs($productData['variations'])
     151            'product_specs'              => self::getProductsSpecs($productData['variations']),
     152            'product_description'        => $productData['description'],
     153            'product_attributes'         => $productData['attributes']
    142154        ];
    143155    }
Note: See TracChangeset for help on using the changeset viewer.