Improve the query merging logic

This commit is contained in:
Bart Kalisz 2024-09-11 18:32:22 +02:00 committed by Christopher Allford
parent 2690191cbe
commit 31775d6835
No known key found for this signature in database
GPG Key ID: 80E44C778F08A88E
2 changed files with 2 additions and 4 deletions

View File

@ -62,7 +62,6 @@ const attributes = {
}, },
query: { query: {
orderBy: 'post__in', orderBy: 'post__in',
order: 'desc',
perPage: 5, perPage: 5,
pages: 1, pages: 1,
}, },

View File

@ -19,7 +19,7 @@ class ProductCollection extends AbstractBlock {
*/ */
protected $block_name = 'product-collection'; protected $block_name = 'product-collection';
/** /**
* An associative array of collection handlers. * An associative array of collection handlers.
* *
* @var array<string, callable> $collection_handler_store * @var array<string, callable> $collection_handler_store
@ -55,7 +55,6 @@ class ProductCollection extends AbstractBlock {
*/ */
protected $custom_order_opts = array( 'popularity', 'rating', 'post__in' ); protected $custom_order_opts = array( 'popularity', 'rating', 'post__in' );
/** /**
* The render state of the product collection block. * The render state of the product collection block.
* *
@ -1012,7 +1011,7 @@ class ProductCollection extends AbstractBlock {
* @return array * @return array
*/ */
private function get_custom_orderby_query( $orderby ) { private function get_custom_orderby_query( $orderby ) {
if ( ! in_array( $orderby, $this->custom_order_opts, true ) ) { if ( ! in_array( $orderby, $this->custom_order_opts, true ) || 'post__in' === $orderby ) {
return array( 'orderby' => $orderby ); return array( 'orderby' => $orderby );
} }