@@ -81,34 +81,35 @@ public function execute(\Magento\Framework\Event\Observer $observer)
8181 */
8282 protected function updateData (AdapterInterface $ db , Configuration $ configuration , \Magento \Catalog \Model \Product $ product )
8383 {
84- $ this ->pushData ($ db , $ product , 'description ' , $ configuration ->getDummyContentText ());
85- $ this ->pushData ($ db , $ product , 'short_description ' , $ configuration ->getDummyContentText ());
86- $ this ->pushData ($ db , $ product , 'meta_title ' , $ configuration ->getDummyContentText ());
87- $ this ->pushData ($ db , $ product , 'meta_keyword ' , $ configuration ->getDummyContentText ());
88- $ this ->pushData ($ db , $ product , 'meta_description ' , $ configuration ->getDummyContentText ());
84+ $ this ->pushData ($ db , $ configuration , $ product , 'description ' , $ configuration ->getDummyContentText ());
85+ $ this ->pushData ($ db , $ configuration , $ product , 'short_description ' , $ configuration ->getDummyContentText ());
86+ $ this ->pushData ($ db , $ configuration , $ product , 'meta_title ' , $ configuration ->getDummyContentText ());
87+ $ this ->pushData ($ db , $ configuration , $ product , 'meta_keyword ' , $ configuration ->getDummyContentText ());
88+ $ this ->pushData ($ db , $ configuration , $ product , 'meta_description ' , $ configuration ->getDummyContentText ());
8989
9090 return $ product ;
9191 }
9292
9393 /**
9494 * @param AdapterInterface $db
95+ * @param Configuration $configuration
9596 * @param \Magento\Catalog\Model\Product $product
9697 * @param string $field
9798 * @param string $value
9899 * @throws \Zend_Db_Statement_Exception
99100 */
100- protected function pushData (AdapterInterface $ db , \Magento \Catalog \Model \Product $ product , $ field , $ value )
101+ protected function pushData (AdapterInterface $ db , Configuration $ configuration , \Magento \Catalog \Model \Product $ product , $ field , $ value )
101102 {
102103 // --- Field type TEXT
103104 if ($ this ->hasAttribute ($ db , $ product , self ::ENTITY_FIELD_TYPE_TEXT , $ field )) {
104- $ this ->updateAttributeByQuery ($ db , $ product , self ::ENTITY_FIELD_TYPE_TEXT , $ field , $ value );
105+ $ this ->updateAttributeByQuery ($ db , $ product , self ::ENTITY_FIELD_TYPE_TEXT , $ field , $ value, $ configuration -> isUseOnlyEmpty () );
105106 } else {
106107 $ this ->insertAttributeByQuery ($ db , $ product , self ::ENTITY_FIELD_TYPE_TEXT , $ field , $ value );
107108 }
108109
109110 // --- Field type VARCHAR
110111 if ($ this ->hasAttribute ($ db , $ product , self ::ENTITY_FIELD_TYPE_VARCHAR , $ field )) {
111- $ this ->updateAttributeByQuery ($ db , $ product , self ::ENTITY_FIELD_TYPE_VARCHAR , $ field , $ value );
112+ $ this ->updateAttributeByQuery ($ db , $ product , self ::ENTITY_FIELD_TYPE_VARCHAR , $ field , $ value, $ configuration -> isUseOnlyEmpty () );
112113 } else {
113114 $ this ->insertAttributeByQuery ($ db , $ product , self ::ENTITY_FIELD_TYPE_VARCHAR , $ field , $ value );
114115 }
@@ -193,9 +194,10 @@ protected function getAttributeId(AdapterInterface $db, $field)
193194 * @param string $fieldType
194195 * @param string $field
195196 * @param string $value
197+ * @param boolean $useOnlyEmpty
196198 * @throws \Zend_Db_Statement_Exception
197199 */
198- protected function updateAttributeByQuery (AdapterInterface $ db , \Magento \Catalog \Model \Product $ product , $ fieldType , $ field , $ value )
200+ protected function updateAttributeByQuery (AdapterInterface $ db , \Magento \Catalog \Model \Product $ product , $ fieldType , $ field , $ value, $ useOnlyEmpty )
199201 {
200202 $ query = 'UPDATE
201203 %1$s AS e
@@ -206,6 +208,10 @@ protected function updateAttributeByQuery(AdapterInterface $db, \Magento\Catalog
206208 e.store_id = :storeid AND
207209 e.entity_id = :entityid ' ;
208210
211+ if ($ useOnlyEmpty ) {
212+ $ query .= ' AND (e.value = "" OR e.value IS NULL) ' ;
213+ }
214+
209215 $ queryText = sprintf (
210216 $ query ,
211217 $ db ->getTableName ('catalog_product_entity_ ' . $ fieldType )
0 commit comments