Skip to content

custom_attributes dropped from response when passing expand options #24

@molhar

Description

@molhar

Passing any relation to expand for the storefront products/ API endpoint appears to drop custom_attributes from the response data. Should the inclusion of attribute relations in defaultStoreProductsRelations mean they're always returned?

I've worked around this by handling custom_attributes passed in as a relation to expand:

  async listAndCount(
    selector: ProductSelector & {
      attributes: string[];
      int_attributes: IntAttributeParam;
    },
    config: FindProductConfig = {
      relations: [],
      skip: 0,
      take: 20,
      include_discount_prices: false,
    }
  ): Promise<[Product[], number]> {
    const manager = this.activeManager_;
    const productRepo = manager.withRepository(this.productRepository_);

    if (config.relations?.includes("custom_attributes")) {
      config.relations.push(
        "attribute_values",
        "attribute_values.attribute",
        "int_attribute_values",
        "int_attribute_values.attribute",
      )
      config.relations = config.relations.filter(rel => rel !== "custom_attributes");
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions