From 806c9e1d4abecfd4d37f5110e1211f8d2f9016e2 Mon Sep 17 00:00:00 2001 From: Ivan Bochkarev Date: Tue, 17 Mar 2026 14:56:44 +0600 Subject: [PATCH] feat(grid): add duplicate and publish actions to category-products grid Migration updates ms3_grid_fields config for category-products actions column so that Duplicate and Publish buttons appear in the category products grid. Fixes #143 --- ...e_publish_to_category_products_actions.php | 91 +++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 core/components/minishop3/migrations/20260317120000_add_duplicate_publish_to_category_products_actions.php diff --git a/core/components/minishop3/migrations/20260317120000_add_duplicate_publish_to_category_products_actions.php b/core/components/minishop3/migrations/20260317120000_add_duplicate_publish_to_category_products_actions.php new file mode 100644 index 00000000..ce570e63 --- /dev/null +++ b/core/components/minishop3/migrations/20260317120000_add_duplicate_publish_to_category_products_actions.php @@ -0,0 +1,91 @@ +prefix = $this->getAdapter()->getOption('table_prefix') ?? ''; + $table = $this->prefix . 'ms3_grid_fields'; + $now = date('Y-m-d H:i:s'); + + $config = [ + 'type' => 'actions', + 'actions' => [ + ['name' => 'view', 'handler' => 'view', 'icon' => 'pi-eye', 'label' => 'view'], + ['name' => 'edit', 'handler' => 'edit', 'icon' => 'pi-pencil', 'label' => 'edit'], + [ + 'name' => 'publish', + 'handler' => 'publish', + 'icon' => 'pi-check', + 'iconOff' => 'pi-times', + 'label' => 'publish', + 'labelOff' => 'unpublish', + 'toggleField' => 'published', + ], + ['name' => 'duplicate', 'handler' => 'duplicate', 'icon' => 'pi-copy', 'label' => 'duplicate'], + [ + 'name' => 'delete', + 'handler' => 'delete', + 'icon' => 'pi-trash', + 'label' => 'delete', + 'severity' => 'danger', + 'confirm' => true, + 'confirmMessage' => 'product_delete_confirm_message', + ], + ], + ]; + + $configJson = json_encode($config, JSON_UNESCAPED_UNICODE); + $quoted = $this->getAdapter()->getConnection()->quote($configJson); + + $this->execute( + "UPDATE `{$table}` SET config = {$quoted}, updated_at = '{$now}' " . + "WHERE grid_key = 'category-products' AND field_name = 'actions'" + ); + } + + public function down(): void + { + $this->prefix = $this->getAdapter()->getOption('table_prefix') ?? ''; + $table = $this->prefix . 'ms3_grid_fields'; + $now = date('Y-m-d H:i:s'); + + $config = [ + 'type' => 'actions', + 'actions' => [ + ['name' => 'view', 'handler' => 'view', 'icon' => 'pi-eye', 'label' => 'view'], + ['name' => 'edit', 'handler' => 'edit', 'icon' => 'pi-pencil', 'label' => 'edit'], + [ + 'name' => 'delete', + 'handler' => 'delete', + 'icon' => 'pi-trash', + 'label' => 'delete', + 'severity' => 'danger', + 'confirm' => true, + 'confirmMessage' => 'product_delete_confirm_message', + ], + ], + ]; + + $configJson = json_encode($config, JSON_UNESCAPED_UNICODE); + $quoted = $this->getAdapter()->getConnection()->quote($configJson); + + $this->execute( + "UPDATE `{$table}` SET config = {$quoted}, updated_at = '{$now}' " . + "WHERE grid_key = 'category-products' AND field_name = 'actions'" + ); + } +}