From d5488523802656b9c2dd9f29421b10786135fe7b Mon Sep 17 00:00:00 2001 From: Karol Manijak <20098064+kmanijak@users.noreply.github.com> Date: Wed, 18 Oct 2023 12:47:55 +0200 Subject: [PATCH] Simplify Product Collection query attributes by removing attributes which are never used (https://github.com/woocommerce/woocommerce-blocks/pull/11259) * Simply Product Collection query attribute by removing sticky and parents which are never used * Remove parents attribute from migration logic --- ...migration-from-product-collection-to-products.ts | 1 - ...migration-from-products-to-product-collection.ts | 1 - .../js/blocks/product-collection/constants.ts | 2 -- .../assets/js/blocks/product-collection/types.ts | 2 -- .../assets/js/blocks/product-template/edit.tsx | 13 ------------- .../src/BlockTypes/CollectionFilters.php | 1 - 6 files changed, 20 deletions(-) diff --git a/plugins/woocommerce-blocks/assets/js/blocks/migration-products-to-product-collection/migration-from-product-collection-to-products.ts b/plugins/woocommerce-blocks/assets/js/blocks/migration-products-to-product-collection/migration-from-product-collection-to-products.ts index 722969f2d59..6c55cf0d981 100644 --- a/plugins/woocommerce-blocks/assets/js/blocks/migration-products-to-product-collection/migration-from-product-collection-to-products.ts +++ b/plugins/woocommerce-blocks/assets/js/blocks/migration-products-to-product-collection/migration-from-product-collection-to-products.ts @@ -35,7 +35,6 @@ const mapAttributes = ( attributes ) => { woocommerceOnSale, woocommerceHandPickedProducts, taxQuery, - parents, isProductCollectionBlock, ...restQuery } = query; diff --git a/plugins/woocommerce-blocks/assets/js/blocks/migration-products-to-product-collection/migration-from-products-to-product-collection.ts b/plugins/woocommerce-blocks/assets/js/blocks/migration-products-to-product-collection/migration-from-products-to-product-collection.ts index dca5dd9d6d2..c617a6f4a01 100644 --- a/plugins/woocommerce-blocks/assets/js/blocks/migration-products-to-product-collection/migration-from-products-to-product-collection.ts +++ b/plugins/woocommerce-blocks/assets/js/blocks/migration-products-to-product-collection/migration-from-products-to-product-collection.ts @@ -49,7 +49,6 @@ const mapAttributes = ( attributes: Record< string, unknown > ) => { woocommerceOnSale: __woocommerceOnSale, woocommerceHandPickedProducts: include, taxQuery: {}, - parents: [], isProductCollectionBlock: true, ...restQuery, }, diff --git a/plugins/woocommerce-blocks/assets/js/blocks/product-collection/constants.ts b/plugins/woocommerce-blocks/assets/js/blocks/product-collection/constants.ts index daf227d046e..5647db7c99d 100644 --- a/plugins/woocommerce-blocks/assets/js/blocks/product-collection/constants.ts +++ b/plugins/woocommerce-blocks/assets/js/blocks/product-collection/constants.ts @@ -43,10 +43,8 @@ export const DEFAULT_QUERY: ProductCollectionQuery = { author: '', search: '', exclude: [], - sticky: '', inherit: null, taxQuery: {}, - parents: [], isProductCollectionBlock: true, woocommerceOnSale: false, woocommerceStockStatus: getDefaultStockStatuses(), diff --git a/plugins/woocommerce-blocks/assets/js/blocks/product-collection/types.ts b/plugins/woocommerce-blocks/assets/js/blocks/product-collection/types.ts index e42b77fffc6..1b27dee172f 100644 --- a/plugins/woocommerce-blocks/assets/js/blocks/product-collection/types.ts +++ b/plugins/woocommerce-blocks/assets/js/blocks/product-collection/types.ts @@ -35,11 +35,9 @@ export interface ProductCollectionQuery { order: TProductCollectionOrder; orderBy: TProductCollectionOrderBy; pages: number; - parents: number[]; perPage: number; postType: string; search: string; - sticky: string; taxQuery: Record< string, number[] >; woocommerceOnSale: boolean; /** diff --git a/plugins/woocommerce-blocks/assets/js/blocks/product-template/edit.tsx b/plugins/woocommerce-blocks/assets/js/blocks/product-template/edit.tsx index c60354a9035..2009d769ebc 100644 --- a/plugins/woocommerce-blocks/assets/js/blocks/product-template/edit.tsx +++ b/plugins/woocommerce-blocks/assets/js/blocks/product-template/edit.tsx @@ -80,10 +80,8 @@ const ProductTemplateEdit = ( { author, search, exclude, - sticky, inherit, taxQuery, - parents, pages, ...restQueryArgs }, @@ -165,15 +163,6 @@ const ProductTemplateEdit = ( { if ( exclude?.length ) { query.exclude = exclude; } - if ( parents?.length ) { - query.parent = parents; - } - // If sticky is not set, it will return all products in the results. - // If sticky is set to `only`, it will limit the results to sticky products only. - // If it is anything else, it will exclude sticky products from results. For the record the value stored is `exclude`. - if ( sticky ) { - query.sticky = sticky === 'only'; - } // If `inherit` is truthy, adjust conditionally the query to create a better preview. if ( inherit ) { if ( templateCategory ) { @@ -200,11 +189,9 @@ const ProductTemplateEdit = ( { search, postType, exclude, - sticky, inherit, templateSlug, taxQuery, - parents, restQueryArgs, ] ); diff --git a/plugins/woocommerce-blocks/src/BlockTypes/CollectionFilters.php b/plugins/woocommerce-blocks/src/BlockTypes/CollectionFilters.php index 5db863e88b3..e00d4ef4fa2 100644 --- a/plugins/woocommerce-blocks/src/BlockTypes/CollectionFilters.php +++ b/plugins/woocommerce-blocks/src/BlockTypes/CollectionFilters.php @@ -234,7 +234,6 @@ final class CollectionFilters extends AbstractBlock { $mapped_params = array( 'orderBy' => 'orderby', 'pages' => 'page', - 'parents' => 'parent', 'perPage' => 'per_page', 'woocommerceStockStatus' => 'stock_status', 'woocommerceOnSale' => 'on_sale',