diff --git a/src/api/brand/content-types/brand/schema.json b/src/api/brand/content-types/brand/schema.json index 890324b..f21cb29 100644 --- a/src/api/brand/content-types/brand/schema.json +++ b/src/api/brand/content-types/brand/schema.json @@ -58,6 +58,12 @@ "localized": true } } + }, + "products": { + "type": "relation", + "relation": "oneToMany", + "target": "api::product.product", + "mappedBy": "brand" } } } diff --git a/src/api/category/content-types/category/schema.json b/src/api/category/content-types/category/schema.json index 637972a..65b390b 100644 --- a/src/api/category/content-types/category/schema.json +++ b/src/api/category/content-types/category/schema.json @@ -64,6 +64,12 @@ "relation": "manyToMany", "target": "api::category.category", "inversedBy": "parentCategories" + }, + "products": { + "type": "relation", + "relation": "manyToMany", + "target": "api::product.product", + "mappedBy": "categories" } } } diff --git a/src/api/product/content-types/product/schema.json b/src/api/product/content-types/product/schema.json new file mode 100644 index 0000000..48ed38f --- /dev/null +++ b/src/api/product/content-types/product/schema.json @@ -0,0 +1,71 @@ +{ + "kind": "collectionType", + "collectionName": "products", + "info": { + "singularName": "product", + "pluralName": "products", + "displayName": "Product" + }, + "options": { + "draftAndPublish": true + }, + "pluginOptions": { + "i18n": { + "localized": true + } + }, + "attributes": { + "name": { + "pluginOptions": { + "i18n": { + "localized": true + } + }, + "type": "string" + }, + "title": { + "pluginOptions": { + "i18n": { + "localized": true + } + }, + "type": "string" + }, + "slug": { + "pluginOptions": { + "i18n": { + "localized": true + } + }, + "type": "string" + }, + "brand": { + "type": "relation", + "relation": "manyToOne", + "target": "api::brand.brand", + "inversedBy": "products" + }, + "callout": { + "pluginOptions": { + "i18n": { + "localized": true + } + }, + "type": "blocks" + }, + "description": { + "pluginOptions": { + "i18n": { + "localized": true + } + }, + "type": "blocks" + }, + "categories": { + "type": "relation", + "relation": "manyToMany", + "target": "api::category.category", + "inversedBy": "products" + } + } +} diff --git a/src/api/product/controllers/product.ts b/src/api/product/controllers/product.ts new file mode 100644 index 0000000..c63694c --- /dev/null +++ b/src/api/product/controllers/product.ts @@ -0,0 +1,7 @@ +/** + * product controller + */ + +import { factories } from '@strapi/strapi' + +export default factories.createCoreController('api::product.product'); diff --git a/src/api/product/routes/product.ts b/src/api/product/routes/product.ts new file mode 100644 index 0000000..d89b7db --- /dev/null +++ b/src/api/product/routes/product.ts @@ -0,0 +1,7 @@ +/** + * product router + */ + +import { factories } from '@strapi/strapi'; + +export default factories.createCoreRouter('api::product.product'); diff --git a/src/api/product/services/product.ts b/src/api/product/services/product.ts new file mode 100644 index 0000000..6cf417e --- /dev/null +++ b/src/api/product/services/product.ts @@ -0,0 +1,7 @@ +/** + * product service + */ + +import { factories } from '@strapi/strapi'; + +export default factories.createCoreService('api::product.product');