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) 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);