Skip to content

Commit

Permalink
PR #1! Product Model Expansion
Browse files Browse the repository at this point in the history
  • Loading branch information
ediazjz authored Aug 4, 2022
2 parents aae817d + 80debcc commit 8eefac6
Show file tree
Hide file tree
Showing 13 changed files with 224 additions and 42 deletions.
42 changes: 42 additions & 0 deletions src/api/collection/content-types/collection/schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"kind": "collectionType",
"collectionName": "collections",
"info": {
"singularName": "collection",
"pluralName": "collections",
"displayName": "Collection",
"description": ""
},
"options": {
"draftAndPublish": true
},
"pluginOptions": {},
"attributes": {
"title": {
"type": "string",
"required": true
},
"slug": {
"type": "uid",
"targetField": "title",
"required": true
},
"description": {
"type": "richtext"
},
"image": {
"type": "media",
"multiple": false,
"required": false,
"allowedTypes": [
"images"
]
},
"products": {
"type": "relation",
"relation": "manyToMany",
"target": "api::product.product",
"inversedBy": "collections"
}
}
}
9 changes: 9 additions & 0 deletions src/api/collection/controllers/collection.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use strict';

/**
* collection controller
*/

const { createCoreController } = require('@strapi/strapi').factories;

module.exports = createCoreController('api::collection.collection');
9 changes: 9 additions & 0 deletions src/api/collection/routes/collection.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use strict';

/**
* collection router.
*/

const { createCoreRouter } = require('@strapi/strapi').factories;

module.exports = createCoreRouter('api::collection.collection');
9 changes: 9 additions & 0 deletions src/api/collection/services/collection.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use strict';

/**
* collection service.
*/

const { createCoreService } = require('@strapi/strapi').factories;

module.exports = createCoreService('api::collection.collection');
26 changes: 26 additions & 0 deletions src/api/product-type/content-types/product-type/schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"kind": "collectionType",
"collectionName": "product_types",
"info": {
"singularName": "product-type",
"pluralName": "product-types",
"displayName": "Product Type",
"description": ""
},
"options": {
"draftAndPublish": false
},
"pluginOptions": {},
"attributes": {
"name": {
"type": "string",
"required": true,
"unique": false
},
"slug": {
"type": "uid",
"targetField": "name",
"required": true
}
}
}
9 changes: 9 additions & 0 deletions src/api/product-type/controllers/product-type.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use strict';

/**
* product-type controller
*/

const { createCoreController } = require('@strapi/strapi').factories;

module.exports = createCoreController('api::product-type.product-type');
9 changes: 9 additions & 0 deletions src/api/product-type/routes/product-type.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use strict';

/**
* product-type router.
*/

const { createCoreRouter } = require('@strapi/strapi').factories;

module.exports = createCoreRouter('api::product-type.product-type');
9 changes: 9 additions & 0 deletions src/api/product-type/services/product-type.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use strict';

/**
* product-type service.
*/

const { createCoreService } = require('@strapi/strapi').factories;

module.exports = createCoreService('api::product-type.product-type');
92 changes: 50 additions & 42 deletions src/api/product/content-types/product/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,64 +8,72 @@
"description": ""
},
"options": {
"draftAndPublish": false
},
"pluginOptions": {
"i18n": {
"localized": true
}
"draftAndPublish": true
},
"pluginOptions": {},
"attributes": {
"title": {
"pluginOptions": {
"i18n": {
"localized": true
}
},
"type": "string",
"required": true,
"unique": true
"unique": false
},
"description": {
"pluginOptions": {
"i18n": {
"localized": true
}
},
"type": "text",
"slug": {
"type": "uid",
"targetField": "title",
"required": true
},
"image": {
"description": {
"type": "richtext"
},
"media": {
"type": "media",
"multiple": false,
"multiple": true,
"required": true,
"allowedTypes": [
"images"
],
"pluginOptions": {
"i18n": {
"localized": true
}
}
},
"slug": {
"pluginOptions": {
"i18n": {
"localized": true
}
},
"type": "uid",
"targetField": "title",
"required": true
"pluginOptions": {}
},
"price": {
"pluginOptions": {
"i18n": {
"localized": false
}
},
"type": "float",
"required": true
"required": true,
"unique": false,
"min": 0
},
"compareAtPrice": {
"type": "float",
"min": 0
},
"costPerItem": {
"type": "float",
"required": true,
"min": 0
},
"inventory": {
"type": "integer",
"required": true,
"min": 1
},
"sellWithoutStock": {
"type": "boolean",
"default": false,
"required": false
},
"productType": {
"type": "relation",
"relation": "oneToOne",
"target": "api::product-type.product-type"
},
"tags": {
"type": "relation",
"relation": "oneToMany",
"target": "api::tag.tag"
},
"collections": {
"type": "relation",
"relation": "manyToMany",
"target": "api::collection.collection",
"mappedBy": "products"
}
}
}
25 changes: 25 additions & 0 deletions src/api/tag/content-types/tag/schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"kind": "collectionType",
"collectionName": "tags",
"info": {
"singularName": "tag",
"pluralName": "tags",
"displayName": "Tag",
"description": ""
},
"options": {
"draftAndPublish": false
},
"pluginOptions": {},
"attributes": {
"name": {
"type": "string",
"required": true
},
"slug": {
"type": "uid",
"targetField": "name",
"required": true
}
}
}
9 changes: 9 additions & 0 deletions src/api/tag/controllers/tag.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use strict';

/**
* tag controller
*/

const { createCoreController } = require('@strapi/strapi').factories;

module.exports = createCoreController('api::tag.tag');
9 changes: 9 additions & 0 deletions src/api/tag/routes/tag.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use strict';

/**
* tag router.
*/

const { createCoreRouter } = require('@strapi/strapi').factories;

module.exports = createCoreRouter('api::tag.tag');
9 changes: 9 additions & 0 deletions src/api/tag/services/tag.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use strict';

/**
* tag service.
*/

const { createCoreService } = require('@strapi/strapi').factories;

module.exports = createCoreService('api::tag.tag');

0 comments on commit 8eefac6

Please sign in to comment.