diff --git a/src/app/code/community/Meanbee/AutoCategories/Model/Auto/Category/Abstract.php b/src/app/code/community/Meanbee/AutoCategories/Model/Auto/Category/Abstract.php index 6cb8241..e2f5e98 100644 --- a/src/app/code/community/Meanbee/AutoCategories/Model/Auto/Category/Abstract.php +++ b/src/app/code/community/Meanbee/AutoCategories/Model/Auto/Category/Abstract.php @@ -63,7 +63,7 @@ public function getCategory() { public function getProductCollection() { $collection = $this->getData('product_collection'); if (is_null($collection)) { - $collection = Mage::getModel('catalog/product')->getCollection(); + $collection = Mage::getResourceModel('catalog/product_collection'); $this->applyFilter($collection); @@ -90,6 +90,9 @@ public function maintain($products = array()) { return; } + $originalStore = Mage::app()->getStore(); + Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID); + $collection = clone $this->getProductCollection(); // Remove products not matching the filter anymore @@ -122,6 +125,8 @@ public function maintain($products = array()) { $insert = $select->insertIgnoreFromSelect($this->getCategoryProductTable(), array('category_id', 'product_id', 'position')); $this->getConnection()->query($insert); + + Mage::app()->setCurrentStore($originalStore); } /** diff --git a/src/app/code/community/Meanbee/AutoCategories/etc/config.xml b/src/app/code/community/Meanbee/AutoCategories/etc/config.xml index 4799b41..eeaba2f 100644 --- a/src/app/code/community/Meanbee/AutoCategories/etc/config.xml +++ b/src/app/code/community/Meanbee/AutoCategories/etc/config.xml @@ -2,7 +2,7 @@ - 1.0.0 + 1.0.1 diff --git a/src/app/code/community/Meanbee/SaleCategory/Model/Auto/Category/Sale.php b/src/app/code/community/Meanbee/SaleCategory/Model/Auto/Category/Sale.php index 0ba14ca..9538b2c 100644 --- a/src/app/code/community/Meanbee/SaleCategory/Model/Auto/Category/Sale.php +++ b/src/app/code/community/Meanbee/SaleCategory/Model/Auto/Category/Sale.php @@ -14,7 +14,9 @@ protected function applyFilter($collection) { $now = $this->getCurrentDate()->toString('YYYY-MM-dd HH:mm:ss'); $collection + ->addAttributeToFilter("price", array("notnull" => true)) ->addAttributeToFilter("special_price", array("notnull" => true)) + ->addAttributeToFilter("special_price", array("lt" => new Zend_Db_Expr("at_price.value"))) ->addAttributeToFilter("special_from_date", array( array("null" => true), array("lteq" => $now) diff --git a/src/app/code/community/Meanbee/SaleCategory/etc/config.xml b/src/app/code/community/Meanbee/SaleCategory/etc/config.xml index 43b96df..6a477da 100644 --- a/src/app/code/community/Meanbee/SaleCategory/etc/config.xml +++ b/src/app/code/community/Meanbee/SaleCategory/etc/config.xml @@ -2,7 +2,7 @@ - 1.0.0 + 1.0.1