This commit is contained in:
@@ -7,7 +7,6 @@
|
|||||||
/packages/medusa/src/services/middleware.js
|
/packages/medusa/src/services/middleware.js
|
||||||
/packages/medusa/src/services/oauth.js
|
/packages/medusa/src/services/oauth.js
|
||||||
/packages/medusa/src/services/payment-provider.js
|
/packages/medusa/src/services/payment-provider.js
|
||||||
/packages/medusa/src/services/product-collection.js
|
|
||||||
/packages/medusa/src/services/product-variant.js
|
/packages/medusa/src/services/product-variant.js
|
||||||
/packages/medusa/src/services/product.js
|
/packages/medusa/src/services/product.js
|
||||||
/packages/medusa/src/services/shipping-profile.js
|
/packages/medusa/src/services/shipping-profile.js
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
import _ from "lodash"
|
|
||||||
import { BaseService } from "medusa-interfaces"
|
import { BaseService } from "medusa-interfaces"
|
||||||
import { MedusaError } from "medusa-core-utils"
|
import { MedusaError } from "medusa-core-utils"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides layer to manipulate product collections.
|
* Provides layer to manipulate product collections.
|
||||||
* @implements BaseService
|
* @extends BaseService
|
||||||
*/
|
*/
|
||||||
class ProductCollectionService extends BaseService {
|
class ProductCollectionService extends BaseService {
|
||||||
constructor({
|
constructor({
|
||||||
@@ -48,6 +47,7 @@ class ProductCollectionService extends BaseService {
|
|||||||
/**
|
/**
|
||||||
* Retrieves a product collection by id.
|
* Retrieves a product collection by id.
|
||||||
* @param {string} collectionId - the id of the collection to retrieve.
|
* @param {string} collectionId - the id of the collection to retrieve.
|
||||||
|
* @param {Object} config - the config of the collection to retrieve.
|
||||||
* @return {Promise<ProductCollection>} the collection.
|
* @return {Promise<ProductCollection>} the collection.
|
||||||
*/
|
*/
|
||||||
async retrieve(collectionId, config = {}) {
|
async retrieve(collectionId, config = {}) {
|
||||||
@@ -76,7 +76,7 @@ class ProductCollectionService extends BaseService {
|
|||||||
* @return {Promise<ProductCollection>} created collection
|
* @return {Promise<ProductCollection>} created collection
|
||||||
*/
|
*/
|
||||||
async create(collection) {
|
async create(collection) {
|
||||||
return this.atomicPhase_(async manager => {
|
return this.atomicPhase_(async (manager) => {
|
||||||
const collectionRepo = manager.getCustomRepository(
|
const collectionRepo = manager.getCustomRepository(
|
||||||
this.productCollectionRepository_
|
this.productCollectionRepository_
|
||||||
)
|
)
|
||||||
@@ -93,7 +93,7 @@ class ProductCollectionService extends BaseService {
|
|||||||
* @return {Promise<ProductCollection>} update collection
|
* @return {Promise<ProductCollection>} update collection
|
||||||
*/
|
*/
|
||||||
async update(collectionId, update) {
|
async update(collectionId, update) {
|
||||||
return this.atomicPhase_(async manager => {
|
return this.atomicPhase_(async (manager) => {
|
||||||
const collectionRepo = manager.getCustomRepository(
|
const collectionRepo = manager.getCustomRepository(
|
||||||
this.productCollectionRepository_
|
this.productCollectionRepository_
|
||||||
)
|
)
|
||||||
@@ -120,14 +120,16 @@ class ProductCollectionService extends BaseService {
|
|||||||
* @return {Promise} empty promise
|
* @return {Promise} empty promise
|
||||||
*/
|
*/
|
||||||
async delete(collectionId) {
|
async delete(collectionId) {
|
||||||
return this.atomicPhase_(async manager => {
|
return this.atomicPhase_(async (manager) => {
|
||||||
const productCollectionRepo = manager.getCustomRepository(
|
const productCollectionRepo = manager.getCustomRepository(
|
||||||
this.productCollectionRepository_
|
this.productCollectionRepository_
|
||||||
)
|
)
|
||||||
|
|
||||||
const collection = await this.retrieve(collectionId)
|
const collection = await this.retrieve(collectionId)
|
||||||
|
|
||||||
if (!collection) return Promise.resolve()
|
if (!collection) {
|
||||||
|
return Promise.resolve()
|
||||||
|
}
|
||||||
|
|
||||||
await productCollectionRepo.softRemove(collection)
|
await productCollectionRepo.softRemove(collection)
|
||||||
|
|
||||||
@@ -138,6 +140,7 @@ class ProductCollectionService extends BaseService {
|
|||||||
/**
|
/**
|
||||||
* Lists product collections
|
* Lists product collections
|
||||||
* @param {Object} selector - the query object for find
|
* @param {Object} selector - the query object for find
|
||||||
|
* @param {Object} config - the config to be used for find
|
||||||
* @return {Promise} the result of the find operation
|
* @return {Promise} the result of the find operation
|
||||||
*/
|
*/
|
||||||
async list(selector = {}, config = { skip: 0, take: 20 }) {
|
async list(selector = {}, config = { skip: 0, take: 20 }) {
|
||||||
|
|||||||
Reference in New Issue
Block a user