vholik / medusa-custom-attributes

Plugin that extends MedusaJs with custom attributes API
70 stars 17 forks source link

Problem visiting product page on admin #20

Closed alexandrosk closed 4 months ago

alexandrosk commented 4 months ago
error:   Relation with property path attribute_values in entity was not found.
TypeORMError: Relation with property path attribute_values in entity was not found.

Making a new product also gives me this

Relation with property path attribute_values in entity was not found. TypeORMError: Relation with property path attribute_values in entity was not found. at JoinAttribute.getValue (/Users/xxx/sites/medusa-store/node_modules/typeorm/query-builder/JoinAttribute.js:109:23) at get relation [as relation]

alexandrosk commented 4 months ago

You can see my code here, Im reusing some functionalities from another marketplace code https://github.com/alexandrosk/medusa-marketplace

And as you mentioned already it overrides through loaders (but I commented it out)

vholik commented 4 months ago

Problem is that you extended product with Medusa product repository and not plugin product repository. Try to extend your repository and model using medusa-custom-attributes.

import { Product } from "../models/product";
import { dataSource } from "@medusajs/medusa/dist/loaders/database";
// Import from plugin
import { ProductRepository as MedusaProductRepository } from "medusa-custom-attributes/dist/repositories/product";

export const ProductRepository = dataSource.getRepository(Product).extend(
    Object.assign(MedusaProductRepository, {
      customFunction(): void {
        // TODO add custom implementation
        return
      }
    }),
);

export default ProductRepository;
alexandrosk commented 4 months ago

Wow that solved, still learning Medusa, thanks! was great help man!

alexandrosk commented 4 months ago

I would love a demo with nextjs filters working as well, since its a bit hard to follow the guide on Medium as it seems its using a previous version, but either way you're doing astonish work thanks man!