From a2eabeb8d25c9db96a06d1e753e08005cc8e998d Mon Sep 17 00:00:00 2001 From: Anthony Bates Date: Mon, 7 Oct 2024 10:18:56 +0100 Subject: [PATCH 1/2] Update Node.php Add Resource Model to __construct so that the connection table name comes through with any prefixes --- Model/ResourceModel/Menu/Node.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Model/ResourceModel/Menu/Node.php b/Model/ResourceModel/Menu/Node.php index 8f0609fd..fdfe8b77 100644 --- a/Model/ResourceModel/Menu/Node.php +++ b/Model/ResourceModel/Menu/Node.php @@ -8,17 +8,21 @@ use Magento\Framework\Model\ResourceModel\Db\AbstractDb; use Magento\Framework\Model\ResourceModel\Db\Context; use Magento\Framework\Serialize\SerializerInterface; +use Magento\Framework\App\ResourceConnection; class Node extends AbstractDb { protected $serializer; + protected $resource; public function __construct( Context $context, SerializerInterface $serializer, + ResourceConnection $resource, $connectionName = null ) { $this->serializer = $serializer; + $this->resource = $resource; parent::__construct($context, $connectionName); } @@ -29,8 +33,9 @@ protected function _construct() protected function _afterSave(AbstractModel $object) { - $connection = $this->getConnection(); - $connection->delete('snowmenu_customer', ['node_id = ?' => $object->getNodeId()]); + $connection = $this->resource->getConnection(); + $tableName = $this->resource->getTableName('snowmenu_customer'); + $connection->delete($tableName, ['node_id = ?' => $object->getNodeId()]); $nodeCustomerGroups = $object->getData('customer_groups'); if ($nodeCustomerGroups && is_string($nodeCustomerGroups)) { @@ -44,7 +49,7 @@ protected function _afterSave(AbstractModel $object) ]; } if ($nodeCustomerGroups) { - $connection->insertMultiple('snowmenu_customer', $insertData); + $connection->insertMultiple($tableName, $insertData); } return parent::_afterSave($object); From bdf249b1f43afb397001b20e8b4c96a2d236a530 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20Wac=C5=82awczyk?= Date: Fri, 8 Nov 2024 07:26:08 +0100 Subject: [PATCH 2/2] bump 2.27.2 --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f81fe4b6..9bf1ad8e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +## [2.27.2] - 2024-11-08 +### Fixed +- Issue when saving nodes w/ db prefix ([#345](https://github.com/SnowdogApps/magento2-menu/pull/345)) + ## [2.27.1] - 2024-08-07 ### Fixed - Swagger docs (#332)