diff --git a/app/etc/di.xml b/app/etc/di.xml
index cc7d10e56bb0e..8d26169307a5f 100755
--- a/app/etc/di.xml
+++ b/app/etc/di.xml
@@ -1330,4 +1330,11 @@
Magento\Config\App\Config\Source\EnvironmentConfigSource
+
+
+
+ - updated_at
+
+
+
diff --git a/lib/internal/Magento/Framework/DataObject.php b/lib/internal/Magento/Framework/DataObject.php
index 547a23ed979d1..a6ebc50fe98bc 100644
--- a/lib/internal/Magento/Framework/DataObject.php
+++ b/lib/internal/Magento/Framework/DataObject.php
@@ -325,19 +325,21 @@ public function convertToXml(
* Convert object data to JSON
*
* @param array $keys array of required keys
- * @return string
+ * @return bool|string
+ * @throws \InvalidArgumentException
*/
public function toJson(array $keys = [])
{
$data = $this->toArray($keys);
- return \Zend_Json::encode($data);
+ return \Magento\Framework\Serialize\JsonConverter::convert($data);
}
/**
* The "__" style wrapper for toJson
*
- * @param array $keys
- * @return string
+ * @param array $keys
+ * @return bool|string
+ * @throws \InvalidArgumentException
*/
public function convertToJson(array $keys = [])
{
diff --git a/lib/internal/Magento/Framework/Mview/View/Subscription.php b/lib/internal/Magento/Framework/Mview/View/Subscription.php
index e621909ec99b6..11c0ad2e37aeb 100644
--- a/lib/internal/Magento/Framework/Mview/View/Subscription.php
+++ b/lib/internal/Magento/Framework/Mview/View/Subscription.php
@@ -10,6 +10,7 @@
use Magento\Framework\App\ResourceConnection;
use Magento\Framework\DB\Ddl\Trigger;
+use Magento\Framework\Mview\View\StateInterface;
class Subscription implements SubscriptionInterface
{
@@ -52,6 +53,14 @@ class Subscription implements SubscriptionInterface
*/
protected $linkedViews = [];
+ /**
+ * List of columns that can be updated in a subscribed table
+ * without creating a new change log entry
+ *
+ * @var array
+ */
+ private $ignoredUpdateColumns = [];
+
/**
* @var Resource
*/
@@ -64,6 +73,7 @@ class Subscription implements SubscriptionInterface
* @param \Magento\Framework\Mview\ViewInterface $view
* @param string $tableName
* @param string $columnName
+ * @param array $ignoredUpdateColumns
*/
public function __construct(
ResourceConnection $resource,
@@ -71,7 +81,8 @@ public function __construct(
\Magento\Framework\Mview\View\CollectionInterface $viewCollection,
\Magento\Framework\Mview\ViewInterface $view,
$tableName,
- $columnName
+ $columnName,
+ $ignoredUpdateColumns = []
) {
$this->connection = $resource->getConnection();
$this->triggerFactory = $triggerFactory;
@@ -80,6 +91,7 @@ public function __construct(
$this->tableName = $tableName;
$this->columnName = $columnName;
$this->resource = $resource;
+ $this->ignoredUpdateColumns = $ignoredUpdateColumns;
}
/**
@@ -154,7 +166,7 @@ public function remove()
protected function getLinkedViews()
{
if (!$this->linkedViews) {
- $viewList = $this->viewCollection->getViewsByStateMode(\Magento\Framework\Mview\View\StateInterface::MODE_ENABLED);
+ $viewList = $this->viewCollection->getViewsByStateMode(StateInterface::MODE_ENABLED);
foreach ($viewList as $view) {
/** @var \Magento\Framework\Mview\ViewInterface $view */
@@ -175,7 +187,7 @@ protected function getLinkedViews()
}
/**
- * Build trigger statement for INSER, UPDATE, DELETE events
+ * Build trigger statement for INSERT, UPDATE, DELETE events
*
* @param string $event
* @param \Magento\Framework\Mview\View\ChangelogInterface $changelog
@@ -183,27 +195,48 @@ protected function getLinkedViews()
*/
protected function buildStatement($event, $changelog)
{
+ $columns = [];
+ if ($this->connection->isTableExists($this->getTableName())
+ && $describe = $this->connection->describeTable($this->getTableName())
+ ) {
+ foreach ($describe as $column) {
+ if (in_array($column['COLUMN_NAME'], $this->ignoredUpdateColumns)) {
+ continue;
+ }
+ $columns[] = sprintf(
+ 'NEW.%1$s != OLD.%1$s',
+ $this->connection->quoteIdentifier($column['COLUMN_NAME'])
+ );
+ }
+ }
+
switch ($event) {
case Trigger::EVENT_INSERT:
+ $trigger = "INSERT IGNORE INTO %s (%s) VALUES (NEW.%s);";
+ break;
case Trigger::EVENT_UPDATE:
- return sprintf(
- "INSERT IGNORE INTO %s (%s) VALUES (NEW.%s);",
- $this->connection->quoteIdentifier($this->resource->getTableName($changelog->getName())),
- $this->connection->quoteIdentifier($changelog->getColumnName()),
- $this->connection->quoteIdentifier($this->getColumnName())
- );
-
+ $trigger = "INSERT IGNORE INTO %s (%s) VALUES (NEW.%s);";
+ if ($columns) {
+ $trigger = sprintf(
+ "IF (%s) THEN %s END IF;",
+ implode(' OR ', $columns),
+ $trigger
+ );
+ }
+ break;
case Trigger::EVENT_DELETE:
- return sprintf(
- "INSERT IGNORE INTO %s (%s) VALUES (OLD.%s);",
- $this->connection->quoteIdentifier($this->resource->getTableName($changelog->getName())),
- $this->connection->quoteIdentifier($changelog->getColumnName()),
- $this->connection->quoteIdentifier($this->getColumnName())
- );
-
+ $trigger = "INSERT IGNORE INTO %s (%s) VALUES (OLD.%s);";
+ break;
default:
return '';
+
}
+ return sprintf(
+ $trigger,
+ $this->connection->quoteIdentifier($this->resource->getTableName($changelog->getName())),
+ $this->connection->quoteIdentifier($changelog->getColumnName()),
+ $this->connection->quoteIdentifier($this->getColumnName())
+ );
}
/**
diff --git a/lib/internal/Magento/Framework/Serialize/JsonConverter.php b/lib/internal/Magento/Framework/Serialize/JsonConverter.php
new file mode 100644
index 0000000000000..6f6fdfb249408
--- /dev/null
+++ b/lib/internal/Magento/Framework/Serialize/JsonConverter.php
@@ -0,0 +1,28 @@
+serialize($data);
+ }
+}