diff --git a/Actindo/Bootstrap.php b/Actindo/Bootstrap.php index 3235473..378ea36 100755 --- a/Actindo/Bootstrap.php +++ b/Actindo/Bootstrap.php @@ -30,7 +30,7 @@ class Shopware_Plugins_Core_Actindo_Bootstrap extends Shopware_Components_Plugin * the version number MUST match this regex (in order for the update mechanism to work): * ^\d+\.\d+$ */ - const VERSION = '2.270'; + const VERSION = '2.271'; /** * the installed shopware version must be this or greater, otherwise this plugin won't install diff --git a/Actindo/Components/Service/Product.php b/Actindo/Components/Service/Product.php index 1742e1e..5ae583e 100755 --- a/Actindo/Components/Service/Product.php +++ b/Actindo/Components/Service/Product.php @@ -1017,6 +1017,18 @@ protected function updateProduct($articleID, &$product) { $this->_updateVPE($product, $update); $this->_updateVariants($product, $update, $articleID); $articles = $this->resources->article; + /** + * Enlight Filter Event + */ + $update = Enlight_Application::Instance()->Events()->filter( + 'ActindoConnector_Product_Update_ArticleFilter', + $update, + array( + 'subject'=>$this, + 'id'=>$articleID, + 'product'=>$product + ) + ); try { $articles->update($articleID, $update); @@ -1032,9 +1044,18 @@ protected function updateProduct($articleID, &$product) { $firstVariantArticleNumber = current(array_keys($product['shop']['attributes']['combination_advanced'])); $sql = 'SELECT id FROM s_articles_details WHERE ordernumber='.Shopware()->Db()->quote($firstVariantArticleNumber); $result = Shopware()->Db()->query($sql); - $firstVairantArticleId = $result->fetch(PDO::FETCH_ASSOC); - $firstVairantArticleId = $firstVairantArticleId['id']; - $sql = 'UPDATE s_articles SET main_detail_id='.(int)$firstVairantArticleId.' WHERE id='.(int)$articleID.';'; + $firstVariantArticleId = $result->fetch(PDO::FETCH_ASSOC); + $firstVariantArticleId = $firstVairantArticleId['id']; + /** + * Clean Up DB + */ + $sql = 'UPDATE s_articles SET main_detail_id='.(int)$firstVariantArticleId.' WHERE id='.(int)$articleID.';'; + Shopware()->Db()->query($sql); + //Reset Kinds + $sql = 'UPDATE s_articles_details set kind=2 WHERE articleID='.(int)$articleID.';'; + Shopware()->Db()->query($sql); + //now set the main Article ID + $sql = 'UPDATE s_articles_details set kind=1 WHERE id='.(int)$firstVariantArticleId.';'; Shopware()->Db()->query($sql); //trigger update again, it will continue without doing the complete update process (only the stuff that has not been created so far try