├── .gitignore ├── LICENSE.md ├── README.md ├── build.xml ├── modman ├── package ├── Meanbee_AutoCategories.xml ├── Meanbee_NewCategory.xml └── Meanbee_SaleCategory.xml └── src └── app ├── code └── community │ └── Meanbee │ ├── AutoCategories │ ├── Helper │ │ ├── Config.php │ │ └── Data.php │ ├── Model │ │ ├── Auto │ │ │ └── Category │ │ │ │ └── Abstract.php │ │ ├── Cron.php │ │ └── System │ │ │ └── Config │ │ │ └── Source │ │ │ └── Category.php │ ├── Test │ │ ├── Config │ │ │ └── Base.php │ │ └── Model │ │ │ ├── Auto │ │ │ └── Category │ │ │ │ ├── Abstract.php │ │ │ │ └── Abstract │ │ │ │ └── fixtures │ │ │ │ ├── testMaintain.yaml │ │ │ │ ├── testMaintainOnlyAdd.yaml │ │ │ │ ├── testMaintainOnlyRemove.yaml │ │ │ │ └── testMaintainSpecificProducts.yaml │ │ │ ├── Cron.php │ │ │ └── Cron │ │ │ └── fixtures │ │ │ └── testMaintainCategories.yaml │ └── etc │ │ ├── adminhtml.xml │ │ ├── config.xml │ │ └── system.xml │ ├── NewCategory │ ├── Helper │ │ ├── Config.php │ │ └── Data.php │ ├── Model │ │ ├── Auto │ │ │ └── Category │ │ │ │ └── New.php │ │ └── Observer.php │ ├── Test │ │ ├── Config │ │ │ └── Base.php │ │ └── Model │ │ │ ├── Auto │ │ │ └── Category │ │ │ │ ├── New.php │ │ │ │ └── New │ │ │ │ └── fixtures │ │ │ │ └── testMaintain.yaml │ │ │ ├── Observer.php │ │ │ └── Observer │ │ │ ├── fixtures │ │ │ └── testObserveNewProduct.yaml │ │ │ └── providers │ │ │ └── testObserveNewProduct.yaml │ └── etc │ │ ├── config.xml │ │ └── system.xml │ └── SaleCategory │ ├── Helper │ ├── Config.php │ └── Data.php │ ├── Model │ ├── Auto │ │ └── Category │ │ │ └── Sale.php │ └── Observer.php │ ├── Test │ ├── Config │ │ └── Base.php │ └── Model │ │ └── Auto │ │ └── Category │ │ ├── Sale.php │ │ └── Sale │ │ └── fixtures │ │ └── testMaintain.yaml │ └── etc │ ├── config.xml │ └── system.xml └── etc └── modules ├── Meanbee_AutoCategories.xml ├── Meanbee_NewCategory.xml └── Meanbee_SaleCategory.xml /.gitignore: -------------------------------------------------------------------------------- 1 | #################### 2 | # Build files 3 | #################### 4 | phplint.cache 5 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | # Open Software License v. 3.0 (OSL-3.0) 2 | 3 | This Open Software License (the "License") applies to any original work of authorship (the "Original Work") whose owner (the "Licensor") has placed the following licensing notice adjacent to the copyright notice for the Original Work: 4 | 5 | Licensed under the Open Software License version 3.0 6 | 7 | 1) **Grant of Copyright License.** Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, for the duration of the copyright, to do the following: 8 | 9 | a) to reproduce the Original Work in copies, either alone or as part of a collective work; 10 | 11 | b) to translate, adapt, alter, transform, modify, or arrange the Original Work, thereby creating derivative works ("Derivative Works") based upon the Original Work; 12 | 13 | c) to distribute or communicate copies of the Original Work and Derivative Works to the public, _with the proviso that copies of Original Work or Derivative Works that You distribute or communicate shall be licensed under this Open Software License_; 14 | 15 | d) to perform the Original Work publicly; and 16 | 17 | e) to display the Original Work publicly. 18 | 19 | 2) **Grant** of Patent License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, under patent claims owned or controlled by the Licensor that are embodied in the Original Work as furnished by the Licensor, for the duration of the patents, to make, use, sell, offer for sale, have made, and import the Original Work and Derivative Works. 20 | 21 | 3) **Grant** of Source Code License. The term "Source Code" means the preferred form of the Original Work for making modifications to it and all available documentation describing how to modify the Original Work. Licensor agrees to provide a machine-readable copy of the Source Code of the Original Work along with each copy of the Original Work that Licensor distributes. Licensor reserves the right to satisfy this obligation by placing a machine-readable copy of the Source Code in an information repository reasonably calculated to permit inexpensive and convenient access by You for as long as Licensor continues to distribute the Original Work. 22 | 23 | 4) **Exclusions From License Grant.** Neither the names of Licensor, nor the names of any contributors to the Original Work, nor any of their trademarks or service marks, may be used to endorse or promote products derived from this Original Work without express prior permission of the Licensor. Except as expressly stated herein, nothing in this License grants any license to Licensor's trademarks, copyrights, patents, trade secrets or any other intellectual property. No patent license is granted to make, use, sell, offer for sale, have made, or import embodiments of any patent claims other than the licensed claims defined in Section 2\. No license is granted to the trademarks of Licensor even if such marks are included in the Original Work. Nothing in this License shall be interpreted to prohibit Licensor from licensing under terms different from this License any Original Work that Licensor otherwise would have a right to license. 24 | 25 | 5) **External Deployment.** The term "External Deployment" means the use, distribution, or communication of the Original Work or Derivative Works in any way such that the Original Work or Derivative Works may be used by anyone other than You, whether those works are distributed or communicated to those persons or made available as an application intended for use over a network. As an express condition for the grants of license hereunder, You must treat any External Deployment by You of the Original Work or a Derivative Work as a distribution under section 1(c). 26 | 27 | 6) **Attribution Rights.** You must retain, in the Source Code of any Derivative Works that You create, all copyright, patent, or trademark notices from the Source Code of the Original Work, as well as any notices of licensing and any descriptive text identified therein as an "Attribution Notice." You must cause the Source Code for any Derivative Works that You create to carry a prominent Attribution Notice reasonably calculated to inform recipients that You have modified the Original Work. 28 | 29 | 7) **Warranty of Provenance and Disclaimer of Warranty.** Licensor warrants that the copyright in and to the Original Work and the patent rights granted herein by Licensor are owned by the Licensor or are sublicensed to You under the terms of this License with the permission of the contributor(s) of those copyrights and patent rights. Except as expressly stated in the immediately preceding sentence, the Original Work is provided under this License on an "AS IS" BASIS and WITHOUT WARRANTY, either express or implied, including, without limitation, the warranties of non-infringement, merchantability or fitness for a particular purpose. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL WORK IS WITH YOU. This DISCLAIMER OF WARRANTY constitutes an essential part of this License. No license to the Original Work is granted by this License except under this disclaimer. 30 | 31 | 8) **Limitation of Liability.** Under no circumstances and under no legal theory, whether in tort (including negligence), contract, or otherwise, shall the Licensor be liable to anyone for any indirect, special, incidental, or consequential damages of any character arising as a result of this License or the use of the Original Work including, without limitation, damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses. This limitation of liability shall not apply to the extent applicable law prohibits such limitation. 32 | 33 | 9) **Acceptance and Termination.** If, at any time, You expressly assented to this License, that assent indicates your clear and irrevocable acceptance of this License and all of its terms and conditions. If You distribute or communicate copies of the Original Work or a Derivative Work, You must make a reasonable effort under the circumstances to obtain the express assent of recipients to the terms of this License. This License conditions your rights to undertake the activities listed in Section 1, including your right to create Derivative Works based upon the Original Work, and doing so without honoring these terms and conditions is prohibited by copyright law and international treaty. Nothing in this License is intended to affect copyright exceptions and limitations (including "fair use" or "fair dealing"). This License shall terminate immediately and You may no longer exercise any of the rights granted to You by this License upon your failure to honor the conditions in Section 1(c). 34 | 35 | 10) **Termination for Patent Action.** This License shall terminate automatically and You may no longer exercise any of the rights granted to You by this License as of the date You commence an action, including a cross-claim or counterclaim, against Licensor or any licensee alleging that the Original Work infringes a patent. This termination provision shall not apply for an action alleging patent infringement by combinations of the Original Work with other software or hardware. 36 | 37 | 11) **Jurisdiction, Venue and Governing Law.** Any action or suit relating to this License may be brought only in the courts of a jurisdiction wherein the Licensor resides or in which Licensor conducts its primary business, and under the laws of that jurisdiction excluding its conflict-of-law provisions. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any use of the Original Work outside the scope of this License or after its termination shall be subject to the requirements and penalties of copyright or patent law in the appropriate jurisdiction. This section shall survive the termination of this License. 38 | 39 | 12) **Attorneys' Fees.** In any action to enforce the terms of this License or seeking damages relating thereto, the prevailing party shall be entitled to recover its costs and expenses, including, without limitation, reasonable attorneys' fees and costs incurred in connection with such action, including any appeal of such action. This section shall survive the termination of this License. 40 | 41 | 13) **Miscellaneous.** If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. 42 | 43 | 14) **Definition of "You" in This License.** "You" throughout this License, whether in upper or lower case, means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License. For legal entities, "You" includes any entity that controls, is controlled by, or is under common control with you. For purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. 44 | 45 | 15) **Right to Use.** You may use the Original Work in all ways not otherwise restricted or conditioned by this License or by law, and Licensor promises not to interfere with or be responsible for such uses by You. 46 | 47 | 16) **Modification of This License.** This License is Copyright (c) 2005 Lawrence Rosen. Permission is granted to copy, distribute, or communicate this License without modification. Nothing in this License permits You to modify this License as applied to the Original Work or to Derivative Works. However, You may modify the text of this License and copy, distribute or communicate your modified version (the "Modified License") and apply it to other original works of authorship subject to the following conditions: (i) You may not indicate in any way that your Modified License is the "Open Software License" or "OSL" and you may not use those names in the name of your Modified License; (ii) You must replace the notice specified in the first paragraph above with the notice "Licensed under " or with a notice of your own that is not confusingly similar to the notice in this License; and (iii) You may not claim that your original works are open source software unless your Modified License has been approved by Open Source Initiative (OSI) and You comply with its license review and certification process. 48 | 49 | [A brief explanation of this license is available][0]. 50 | 51 | 52 | [0]: http://rosenlaw.com/OSL3.0-explained.htm 53 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Meanbee Category Extensions 2 | ===================== 3 | This repo includes the Meanbee Auto Categories, New Categories, and Sale Categories extensions. 4 | 5 | #### Automatic Sale Categories 6 | Managing sale listings can be a tedious process in Magento. There is no easy way to retrieve a list of products currently on sale and manually adding and removing products from a sale category takes a lot of time and effort. This extension aims to solve that. Simply create your sale category, configure the extension to use it and products will automatically be added to it as they go on sale and removed when the sale ends. 7 | 8 | ###### Features: 9 | - Automatically adds all products with a currently active "special - price" to the sale category 10 | - Immediately adds and removes products when they are changed in the backend 11 | - Refreshes the category products every night - always accurate listings 12 | - Uses a standard magento category - works with layered navigation 13 | 14 | #### Automatic New Categories 15 | This extension automatically manages a category of new products. Simply create a category, configure the extension to use it and new products will automatically be added to it. Use System Configuration to customise when the products are considered to no longer be new and are automatically removed from the category. 16 | 17 | ###### Features: 18 | - Automatically adds new products to a category when they are created 19 | - Refreshes the category every night to remove products which are no longer new 20 | - Allows customising how long the products stay in the category 21 | - Uses a standard Magento category - works with layered navigation 22 | 23 | ##### Compatibility 24 | Compatibility: 1.6, 1.7, 1.8, 1.9 25 | 26 | Support 27 | ------- 28 | You are welcome to log any issues you find for community support but the functionality is provided *as is* and we will not be providing support. We will however review pull requests if you provide one. 29 | 30 | Contribution 31 | ------------ 32 | Any contribution is highly appreciated. The best way to contribute code is to open a [pull request on GitHub](https://help.github.com/articles/using-pull-requests). 33 | 34 | 35 | Licence 36 | ------- 37 | [OSL - Open Software Licence 3.0](http://opensource.org/licenses/osl-3.0.php) 38 | 39 | Copyright 40 | --------- 41 | (c) 2017 Meanbee 42 | -------------------------------------------------------------------------------- /build.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /modman: -------------------------------------------------------------------------------- 1 | # Meanbee_AutoCategories 2 | src/app/etc/modules/* app/etc/modules/ 3 | 4 | src/app/code/community/Meanbee/* app/code/community/Meanbee/ 5 | 6 | package/* var/connect/ 7 | -------------------------------------------------------------------------------- /package/Meanbee_AutoCategories.xml: -------------------------------------------------------------------------------- 1 | <_> 2 | 2ISD4EtqPqKRFrlL 3 | Meanbee_AutoCategories 4 | community 5 | 6 | 2 7 | 8 | Manage products in categories automatically using defined filters. 9 | This extension adds support for automatically managing products in categories based on the filters specified for each category. The extension doesn't do anything on its own and must be installed together with one or more of Meanbee's Automatic Categories. 10 | Commercial License 11 | 12 | 1.0.0 13 | stable 14 | Initial release. 15 | 16 | 17 | Meanbee 18 | 19 | 20 | meanbee 21 | 22 | 23 | hello@meanbee.com 24 | 25 | 26 | 5.2.0 27 | 6.0.0 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | Core 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | magelocal 61 | mageetc 62 | magecommunity 63 | 64 | 65 | 66 | modules/Meanbee_AutoCategories.xml 67 | Meanbee/AutoCategories 68 | 69 | 70 | file 71 | file 72 | dir 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /package/Meanbee_NewCategory.xml: -------------------------------------------------------------------------------- 1 | <_> 2 | F1abOl5fle2tKWel 3 | Meanbee_NewCategory 4 | community 5 | 6 | 2 7 | 8 | Create an automatically managed category for new products. 9 | This extension automatically manages a category for new products. Simply create a category, configure the extension to use it and any new products you create will automatically appear in the category until they're no longer new. You can configure how long a product is considered new in the extension configuration. 10 | 11 | This extension requires Meanbee_AutoCategories to be installed to work. 12 | Commercial License 13 | 14 | 1.0.0 15 | stable 16 | Initial release. 17 | 18 | 19 | Meanbee 20 | 21 | 22 | meanbee 23 | 24 | 25 | hello@meanbee.com 26 | 27 | 28 | 5.2.0 29 | 6.0.0 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | Core 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | magelocal 63 | mageetc 64 | magecommunity 65 | 66 | 67 | 68 | modules/Meanbee_NewCategory.xml 69 | Meanbee/NewCategory 70 | 71 | 72 | file 73 | file 74 | dir 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 1 88 | 200 89 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /package/Meanbee_SaleCategory.xml: -------------------------------------------------------------------------------- 1 | <_> 2 | 2ISD4EtqPqKRFrlL 3 | Meanbee_SaleCategory 4 | community 5 | 6 | 2 7 | 8 | Create an automatically managed Sale category. 9 | This extension automatically manages a Sale category. Simply create a category, configure the extension to use it and products will automatically be added to it when they get discounted and removed once the sale finishes. 10 | 11 | This extension requires Meanbee_AutoCategories to be installed to work. 12 | Commercial License 13 | 14 | 1.0.0 15 | stable 16 | Initial release. 17 | 18 | 19 | Meanbee 20 | 21 | 22 | meanbee 23 | 24 | 25 | hello@meanbee.com 26 | 27 | 28 | 5.2.0 29 | 6.0.0 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | Core 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | magelocal 63 | mageetc 64 | magecommunity 65 | 66 | 67 | 68 | modules/Meanbee_SaleCategory.xml 69 | Meanbee/SaleCategory 70 | 71 | 72 | file 73 | file 74 | dir 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /src/app/code/community/Meanbee/AutoCategories/Helper/Config.php: -------------------------------------------------------------------------------- 1 | getData('module_name'); 36 | if (is_null($module)) { 37 | $class = get_class($this); 38 | $module = substr($class, 0, strpos($class, '_Model')); 39 | $this->setData('module_name', $module); 40 | } 41 | return $module; 42 | } 43 | 44 | /** 45 | * Return the Category model used for this auto category. 46 | * 47 | * @return Mage_Catalog_Model_Category 48 | */ 49 | public function getCategory() { 50 | $category = $this->getData('category'); 51 | if (is_null($category)) { 52 | $category = Mage::getModel('catalog/category')->load($this->getCategoryId()); 53 | $this->setData('category', $category); 54 | } 55 | return $category; 56 | } 57 | 58 | /** 59 | * Return a product collection with filters for products matching this auto category. 60 | * 61 | * @return Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection 62 | */ 63 | public function getProductCollection() { 64 | $collection = $this->getData('product_collection'); 65 | if (is_null($collection)) { 66 | $collection = Mage::getResourceModel('catalog/product_collection'); 67 | 68 | $this->applyFilter($collection); 69 | 70 | $this->setData('product_collection', $collection); 71 | } 72 | return $collection; 73 | } 74 | 75 | /** 76 | * Process the given product ids against the category, adding them if they should be in it 77 | * or removing them if they no longer match the filter. If no products are specified, process 78 | * all products. 79 | * 80 | * @param array $products 81 | */ 82 | public function maintain($products = array()) { 83 | if (!$this->isEnabled()) { 84 | return; 85 | } 86 | 87 | $category_id = $this->getCategoryId(); 88 | if (!$category_id) { 89 | Mage::logException(new Exception(sprintf("%s doesn't have a category id set.", $this->getModuleName()))); 90 | return; 91 | } 92 | 93 | $originalStore = Mage::app()->getStore(); 94 | Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID); 95 | 96 | $collection = clone $this->getProductCollection(); 97 | 98 | // Remove products not matching the filter anymore 99 | $select = clone $collection->getSelect(); 100 | $select 101 | ->reset(Zend_Db_Select::COLUMNS) 102 | ->columns(array('product_id' => 'entity_id')); 103 | $where = array( 104 | 'category_id = ?' => $category_id, 105 | 'product_id NOT IN (?)' => $select 106 | ); 107 | if (!empty($products)) { 108 | $where['product_id IN (?)'] = $products; 109 | } 110 | 111 | $this->getConnection()->delete($this->getCategoryProductTable(), $where); 112 | 113 | // Add products if they match the filter 114 | if (!empty($products)) { 115 | $collection->addIdFilter($products); 116 | } 117 | $select = clone $collection->getSelect(); 118 | $select 119 | ->reset(Zend_Db_Select::COLUMNS) 120 | ->columns(array( 121 | 'category_id' => new Zend_Db_Expr($category_id), 122 | 'product_id' => 'entity_id', 123 | 'position' => $this->getPositionExpr() 124 | )); 125 | $insert = $select->insertIgnoreFromSelect($this->getCategoryProductTable(), array('category_id', 'product_id', 'position')); 126 | 127 | $this->getConnection()->query($insert); 128 | 129 | Mage::app()->setCurrentStore($originalStore); 130 | } 131 | 132 | /** 133 | * Return the database expression for the product position in the category. 134 | * 135 | * @return Zend_Db_Expr 136 | */ 137 | protected function getPositionExpr() { 138 | return new Zend_Db_Expr(0); 139 | } 140 | 141 | /** 142 | * Get a database connection (with write permissions). 143 | * 144 | * @return Zend_Db_Adapter_Abstract 145 | */ 146 | protected function getConnection() { 147 | return Mage::getModel('core/resource')->getConnection('core_write'); 148 | } 149 | 150 | /** 151 | * Return the name of the table used to store products in categories. 152 | * 153 | * @return string 154 | */ 155 | protected function getCategoryProductTable() { 156 | return Mage::getModel('core/resource')->getTableName('catalog/category_product'); 157 | } 158 | } 159 | -------------------------------------------------------------------------------- /src/app/code/community/Meanbee/AutoCategories/Model/Cron.php: -------------------------------------------------------------------------------- 1 | isEnabled()) { 12 | return; 13 | } 14 | 15 | $config = Mage::getConfig()->getNode(self::XML_PATH_AUTO_CATEGORIES); 16 | foreach ($config->children() as $auto_category) { 17 | if ($auto_category->model) { 18 | Mage::getModel((string)$auto_category->model)->maintain(); 19 | } 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/app/code/community/Meanbee/AutoCategories/Model/System/Config/Source/Category.php: -------------------------------------------------------------------------------- 1 | loadByAttribute('parent_id', 0); 9 | 10 | $options = $this->getCategoryTreeAsOptionArray($root_category); 11 | 12 | return $options; 13 | } 14 | 15 | /** 16 | * Recursively traverse the category tree and return all categories (apart from the root) 17 | * as an option array. 18 | * 19 | * @param $root 20 | * @param int $level 21 | * 22 | * @return array 23 | */ 24 | protected function getCategoryTreeAsOptionArray($root, $level = 0) { 25 | $options = array(); 26 | 27 | if ($root->hasChildren()) { 28 | foreach ($root->getChildrenCategories() as $child) { 29 | $options[] = array( 30 | 'label' => sprintf("%s %s", str_repeat(self::PREFIX, $level), $child->getName()), 31 | 'value' => $child->getId() 32 | ); 33 | 34 | $options = array_merge($options, $this->getCategoryTreeAsOptionArray($child, $level + 1)); 35 | } 36 | } 37 | 38 | return $options; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/app/code/community/Meanbee/AutoCategories/Test/Config/Base.php: -------------------------------------------------------------------------------- 1 | assertModelAlias('meanbee_autocategories/test', 'Meanbee_AutoCategories_Model_Test'); 10 | $this->assertHelperAlias('meanbee_autocategories/test', 'Meanbee_AutoCategories_Helper_Test'); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/app/code/community/Meanbee/AutoCategories/Test/Model/Auto/Category/Abstract.php: -------------------------------------------------------------------------------- 1 | getCollection(); 16 | $product_collection->addIdFilter($matching_product_id); 17 | 18 | $auto_category = $this->getMockAutoCategory($category_id, $product_collection); 19 | 20 | $this->assertNotContains($category_id, $this->loadProduct($matching_product_id)->getCategoryIds()); 21 | $this->assertContains($category_id, $this->loadProduct($non_matching_product_id)->getCategoryIds()); 22 | 23 | $auto_category->maintain(); 24 | 25 | $this->assertContains($category_id, $this->loadProduct($matching_product_id)->getCategoryIds()); 26 | $this->assertNotContains($category_id, $this->loadProduct($non_matching_product_id)->getCategoryIds()); 27 | } 28 | 29 | /** 30 | * @test 31 | * @loadFixture 32 | * @doNotIndexAll 33 | */ 34 | public function testMaintainSpecificProducts() { 35 | $category_id = 3; 36 | $matching_product_id = 1; 37 | $non_matching_product_id = 2; 38 | $non_maintained_product = 3; 39 | 40 | $product_collection = Mage::getModel('catalog/product')->getCollection(); 41 | $product_collection->addIdFilter($matching_product_id); 42 | 43 | $auto_category = $this->getMockAutoCategory($category_id, $product_collection); 44 | 45 | $this->assertEquals(array(2, 3), array_keys($this->loadCategory($category_id)->getProductsPosition())); 46 | 47 | $auto_category->maintain(array(1, 2)); 48 | 49 | $this->assertEquals(array(1, 3), array_keys($this->loadCategory($category_id)->getProductsPosition())); 50 | } 51 | 52 | /** 53 | * @test 54 | * @loadFixture 55 | * @doNotIndexAll 56 | */ 57 | public function testMaintainOnlyAdd() { 58 | $category_id = 3; 59 | 60 | $product_collection = Mage::getModel('catalog/product')->getCollection(); 61 | $product_collection->addIdFilter(1); 62 | 63 | $auto_category = $this->getMockAutoCategory($category_id, $product_collection); 64 | 65 | $this->assertEquals(0, $this->loadCategory($category_id)->getProductCount()); 66 | 67 | $auto_category->maintain(); 68 | 69 | $this->assertGreaterThan(0, $this->loadCategory($category_id)->getProductCount()); 70 | } 71 | 72 | /** 73 | * @test 74 | * @loadFixture 75 | * @doNotIndexAll 76 | */ 77 | public function testMaintainOnlyRemove() { 78 | $category_id = 3; 79 | 80 | $product_collection = Mage::getModel('catalog/product')->getCollection(); 81 | $product_collection->addIdFilter(2); 82 | 83 | $auto_category = $this->getMockAutoCategory($category_id, $product_collection); 84 | 85 | $this->assertGreaterThan(0, $this->loadCategory($category_id)->getProductCount()); 86 | 87 | $auto_category->maintain(); 88 | 89 | $this->assertEquals(0, $this->loadCategory($category_id)->getProductCount()); 90 | } 91 | 92 | /** 93 | * @test 94 | * @loadFixture testMaintain.yaml 95 | * @doNotIndexAll 96 | */ 97 | public function testMaintainDisabled() { 98 | $category_id = 3; 99 | 100 | $auto_category = $this->getModelMock( 101 | 'meanbee_autocategories/auto_category_abstract', 102 | array('isEnabled', 'getCategoryid', 'applyFilter'), 103 | true 104 | ); 105 | $auto_category->expects($this->any())->method('isEnabled')->will($this->returnValue(false)); 106 | $auto_category->expects($this->any())->method('getCategoryId')->will($this->returnValue($category_id)); 107 | 108 | $product_collection = Mage::getModel('catalog/product')->getCollection(); 109 | $product_collection->addIdFilter(1); 110 | 111 | $auto_category->setProductCollection($product_collection); 112 | 113 | $this->assertEquals(array(2), array_keys($this->loadCategory($category_id)->getProductsPosition())); 114 | 115 | $auto_category->maintain(); 116 | 117 | $this->assertEquals(array(2), array_keys($this->loadCategory($category_id)->getProductsPosition())); 118 | } 119 | 120 | protected function loadProduct($id) { 121 | return Mage::getModel('catalog/product')->load($id); 122 | } 123 | 124 | protected function loadCategory($id) { 125 | return Mage::getModel('catalog/category')->load($id); 126 | } 127 | 128 | /** 129 | * Return a Mock of meanbee_autocategories/auto_category_abstract object. 130 | * 131 | * @param int $category_id Category id to use. 132 | * @param Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection $product_collection Product collection to use for filtering. 133 | * 134 | * @return PHPUnit_Framework_MockObject_MockObject 135 | */ 136 | protected function getMockAutoCategory($category_id, $product_collection) { 137 | $auto_category = $this->getModelMock( 138 | 'meanbee_autocategories/auto_category_abstract', 139 | array('isEnabled', 'getCategoryid', 'applyFilter'), 140 | true 141 | ); 142 | $auto_category->expects($this->any())->method('isEnabled')->will($this->returnValue(true)); 143 | $auto_category->expects($this->any())->method('getCategoryId')->will($this->returnValue($category_id)); 144 | 145 | $auto_category->setProductCollection($product_collection); 146 | 147 | return $auto_category; 148 | } 149 | } 150 | -------------------------------------------------------------------------------- /src/app/code/community/Meanbee/AutoCategories/Test/Model/Auto/Category/Abstract/fixtures/testMaintain.yaml: -------------------------------------------------------------------------------- 1 | eav: 2 | catalog_category: 3 | - 4 | entity_id: 3 5 | parent_id: 2 6 | created_at: 2014-02-26 14:27:59 7 | updated_at: 2014-02-26 14:28:09 8 | path: 1/2/3 9 | position: 1 10 | level: 2 11 | children_count: 0 12 | store_id: 1 13 | all_children: null 14 | available_sort_by: 15 | children: null 16 | custom_apply_to_products: 0 17 | custom_design: 18 | custom_design_from: 0000-00-00 00:00:00 19 | custom_design_to: 0000-00-00 00:00:00 20 | custom_layout_update: 21 | custom_use_parent_settings: 0 22 | default_sort_by: 23 | description: This is a test 24 | display_mode: PRODUCTS 25 | filter_price_range: 0 26 | image: 27 | include_in_menu: 1 28 | is_active: 1 29 | is_anchor: 0 30 | landing_page: 0 31 | meta_description: 32 | meta_keywords: 33 | meta_title: 34 | name: Test Category 35 | page_layout: 36 | path_in_store: null 37 | thumbnail: 38 | url_key: test-category 39 | url_path: test-category.html 40 | catalog_product: 41 | - 42 | entity_id: 1 43 | attribute_set_id: 4 44 | type_id: simple 45 | cost: null 46 | created_at: 2014-02-26 14:27:29 47 | enable_googlecheckout: 1 48 | gift_message_available: 0 49 | has_options: 0 50 | image_label: null 51 | is_imported: 0 52 | is_recurring: 0 53 | links_exist: null 54 | links_purchased_separately: null 55 | links_title: null 56 | name: Test Product 57 | news_from_date: null 58 | news_to_date: null 59 | price: 100 60 | price_type: null 61 | price_view: null 62 | recurring_profile: null 63 | required_options: 0 64 | shipment_type: null 65 | short_description: Test 66 | sku: test 67 | sku_type: null 68 | small_image: no_selection 69 | small_image_label: null 70 | special_from_date: null 71 | special_price: null 72 | special_to_date: null 73 | tax_class_id: 0 74 | thumbnail: no_selection 75 | thumbnail_label: null 76 | updated_at: 2014-02-26 14:27:29 77 | url_key: test-product 78 | url_path: test-product.html 79 | visibility: 4 80 | weight: 1 81 | weight_type: null 82 | - 83 | entity_id: 2 84 | attribute_set_id: 4 85 | type_id: simple 86 | cost: null 87 | created_at: 2014-02-26 14:27:29 88 | enable_googlecheckout: 1 89 | gift_message_available: 0 90 | has_options: 0 91 | image_label: null 92 | is_imported: 0 93 | is_recurring: 0 94 | links_exist: null 95 | links_purchased_separately: null 96 | links_title: null 97 | name: Test Product 2 98 | news_from_date: null 99 | news_to_date: null 100 | price: 100 101 | price_type: null 102 | price_view: null 103 | recurring_profile: null 104 | required_options: 0 105 | shipment_type: null 106 | short_description: Test 107 | sku: test2 108 | sku_type: null 109 | small_image: no_selection 110 | small_image_label: null 111 | special_from_date: null 112 | special_price: null 113 | special_to_date: null 114 | tax_class_id: 0 115 | thumbnail: no_selection 116 | thumbnail_label: null 117 | updated_at: 2014-02-26 14:27:29 118 | url_key: test-product-2 119 | url_path: test-product-2.html 120 | visibility: 4 121 | weight: 1 122 | weight_type: null 123 | category_ids: 124 | - 3 125 | -------------------------------------------------------------------------------- /src/app/code/community/Meanbee/AutoCategories/Test/Model/Auto/Category/Abstract/fixtures/testMaintainOnlyAdd.yaml: -------------------------------------------------------------------------------- 1 | eav: 2 | catalog_category: 3 | - 4 | entity_id: 3 5 | parent_id: 2 6 | created_at: 2014-02-26 14:27:59 7 | updated_at: 2014-02-26 14:28:09 8 | path: 1/2/3 9 | position: 1 10 | level: 2 11 | children_count: 0 12 | store_id: 1 13 | all_children: null 14 | available_sort_by: 15 | children: null 16 | custom_apply_to_products: 0 17 | custom_design: 18 | custom_design_from: 0000-00-00 00:00:00 19 | custom_design_to: 0000-00-00 00:00:00 20 | custom_layout_update: 21 | custom_use_parent_settings: 0 22 | default_sort_by: 23 | description: This is a test 24 | display_mode: PRODUCTS 25 | filter_price_range: 0 26 | image: 27 | include_in_menu: 1 28 | is_active: 1 29 | is_anchor: 0 30 | landing_page: 0 31 | meta_description: 32 | meta_keywords: 33 | meta_title: 34 | name: Test Category 35 | page_layout: 36 | path_in_store: null 37 | thumbnail: 38 | url_key: test-category 39 | url_path: test-category.html 40 | catalog_product: 41 | - 42 | entity_id: 1 43 | attribute_set_id: 4 44 | type_id: simple 45 | cost: null 46 | created_at: 2014-02-26 14:27:29 47 | enable_googlecheckout: 1 48 | gift_message_available: 0 49 | has_options: 0 50 | image_label: null 51 | is_imported: 0 52 | is_recurring: 0 53 | links_exist: null 54 | links_purchased_separately: null 55 | links_title: null 56 | name: Test Product 57 | news_from_date: null 58 | news_to_date: null 59 | price: 100 60 | price_type: null 61 | price_view: null 62 | recurring_profile: null 63 | required_options: 0 64 | shipment_type: null 65 | short_description: Test 66 | sku: test 67 | sku_type: null 68 | small_image: no_selection 69 | small_image_label: null 70 | special_from_date: null 71 | special_price: null 72 | special_to_date: null 73 | tax_class_id: 0 74 | thumbnail: no_selection 75 | thumbnail_label: null 76 | updated_at: 2014-02-26 14:27:29 77 | url_key: test-product 78 | url_path: test-product.html 79 | visibility: 4 80 | weight: 1 81 | weight_type: null 82 | -------------------------------------------------------------------------------- /src/app/code/community/Meanbee/AutoCategories/Test/Model/Auto/Category/Abstract/fixtures/testMaintainOnlyRemove.yaml: -------------------------------------------------------------------------------- 1 | eav: 2 | catalog_category: 3 | - 4 | entity_id: 3 5 | parent_id: 2 6 | created_at: 2014-02-26 14:27:59 7 | updated_at: 2014-02-26 14:28:09 8 | path: 1/2/3 9 | position: 1 10 | level: 2 11 | children_count: 0 12 | store_id: 1 13 | all_children: null 14 | available_sort_by: 15 | children: null 16 | custom_apply_to_products: 0 17 | custom_design: 18 | custom_design_from: 0000-00-00 00:00:00 19 | custom_design_to: 0000-00-00 00:00:00 20 | custom_layout_update: 21 | custom_use_parent_settings: 0 22 | default_sort_by: 23 | description: This is a test 24 | display_mode: PRODUCTS 25 | filter_price_range: 0 26 | image: 27 | include_in_menu: 1 28 | is_active: 1 29 | is_anchor: 0 30 | landing_page: 0 31 | meta_description: 32 | meta_keywords: 33 | meta_title: 34 | name: Test Category 35 | page_layout: 36 | path_in_store: null 37 | thumbnail: 38 | url_key: test-category 39 | url_path: test-category.html 40 | catalog_product: 41 | - 42 | entity_id: 1 43 | attribute_set_id: 4 44 | type_id: simple 45 | cost: null 46 | created_at: 2014-02-26 14:27:29 47 | enable_googlecheckout: 1 48 | gift_message_available: 0 49 | has_options: 0 50 | image_label: null 51 | is_imported: 0 52 | is_recurring: 0 53 | links_exist: null 54 | links_purchased_separately: null 55 | links_title: null 56 | name: Test Product 57 | news_from_date: null 58 | news_to_date: null 59 | price: 100 60 | price_type: null 61 | price_view: null 62 | recurring_profile: null 63 | required_options: 0 64 | shipment_type: null 65 | short_description: Test 66 | sku: test 67 | sku_type: null 68 | small_image: no_selection 69 | small_image_label: null 70 | special_from_date: null 71 | special_price: null 72 | special_to_date: null 73 | tax_class_id: 0 74 | thumbnail: no_selection 75 | thumbnail_label: null 76 | updated_at: 2014-02-26 14:27:29 77 | url_key: test-product 78 | url_path: test-product.html 79 | visibility: 4 80 | weight: 1 81 | weight_type: null 82 | category_ids: 83 | - 3 84 | -------------------------------------------------------------------------------- /src/app/code/community/Meanbee/AutoCategories/Test/Model/Auto/Category/Abstract/fixtures/testMaintainSpecificProducts.yaml: -------------------------------------------------------------------------------- 1 | eav: 2 | catalog_category: 3 | - 4 | entity_id: 3 5 | parent_id: 2 6 | created_at: 2014-02-26 14:27:59 7 | updated_at: 2014-02-26 14:28:09 8 | path: 1/2/3 9 | position: 1 10 | level: 2 11 | children_count: 0 12 | store_id: 1 13 | all_children: null 14 | available_sort_by: 15 | children: null 16 | custom_apply_to_products: 0 17 | custom_design: 18 | custom_design_from: 0000-00-00 00:00:00 19 | custom_design_to: 0000-00-00 00:00:00 20 | custom_layout_update: 21 | custom_use_parent_settings: 0 22 | default_sort_by: 23 | description: This is a test 24 | display_mode: PRODUCTS 25 | filter_price_range: 0 26 | image: 27 | include_in_menu: 1 28 | is_active: 1 29 | is_anchor: 0 30 | landing_page: 0 31 | meta_description: 32 | meta_keywords: 33 | meta_title: 34 | name: Test Category 35 | page_layout: 36 | path_in_store: null 37 | thumbnail: 38 | url_key: test-category 39 | url_path: test-category.html 40 | catalog_product: 41 | - 42 | entity_id: 1 43 | attribute_set_id: 4 44 | type_id: simple 45 | cost: null 46 | created_at: 2014-02-26 14:27:29 47 | enable_googlecheckout: 1 48 | gift_message_available: 0 49 | has_options: 0 50 | image_label: null 51 | is_imported: 0 52 | is_recurring: 0 53 | links_exist: null 54 | links_purchased_separately: null 55 | links_title: null 56 | name: Test Product 57 | news_from_date: null 58 | news_to_date: null 59 | price: 100 60 | price_type: null 61 | price_view: null 62 | recurring_profile: null 63 | required_options: 0 64 | shipment_type: null 65 | short_description: Test 66 | sku: test 67 | sku_type: null 68 | small_image: no_selection 69 | small_image_label: null 70 | special_from_date: null 71 | special_price: null 72 | special_to_date: null 73 | tax_class_id: 0 74 | thumbnail: no_selection 75 | thumbnail_label: null 76 | updated_at: 2014-02-26 14:27:29 77 | url_key: test-product 78 | url_path: test-product.html 79 | visibility: 4 80 | weight: 1 81 | weight_type: null 82 | - 83 | entity_id: 2 84 | attribute_set_id: 4 85 | type_id: simple 86 | cost: null 87 | created_at: 2014-02-26 14:27:29 88 | enable_googlecheckout: 1 89 | gift_message_available: 0 90 | has_options: 0 91 | image_label: null 92 | is_imported: 0 93 | is_recurring: 0 94 | links_exist: null 95 | links_purchased_separately: null 96 | links_title: null 97 | name: Test Product 2 98 | news_from_date: null 99 | news_to_date: null 100 | price: 100 101 | price_type: null 102 | price_view: null 103 | recurring_profile: null 104 | required_options: 0 105 | shipment_type: null 106 | short_description: Test 107 | sku: test2 108 | sku_type: null 109 | small_image: no_selection 110 | small_image_label: null 111 | special_from_date: null 112 | special_price: null 113 | special_to_date: null 114 | tax_class_id: 0 115 | thumbnail: no_selection 116 | thumbnail_label: null 117 | updated_at: 2014-02-26 14:27:29 118 | url_key: test-product-2 119 | url_path: test-product-2.html 120 | visibility: 4 121 | weight: 1 122 | weight_type: null 123 | category_ids: 124 | - 3 125 | - 126 | entity_id: 3 127 | attribute_set_id: 4 128 | type_id: simple 129 | cost: null 130 | created_at: 2014-02-26 14:27:29 131 | enable_googlecheckout: 1 132 | gift_message_available: 0 133 | has_options: 0 134 | image_label: null 135 | is_imported: 0 136 | is_recurring: 0 137 | links_exist: null 138 | links_purchased_separately: null 139 | links_title: null 140 | name: Test Product 3 141 | news_from_date: null 142 | news_to_date: null 143 | price: 100 144 | price_type: null 145 | price_view: null 146 | recurring_profile: null 147 | required_options: 0 148 | shipment_type: null 149 | short_description: Test 150 | sku: test3 151 | sku_type: null 152 | small_image: no_selection 153 | small_image_label: null 154 | special_from_date: null 155 | special_price: null 156 | special_to_date: null 157 | tax_class_id: 0 158 | thumbnail: no_selection 159 | thumbnail_label: null 160 | updated_at: 2014-02-26 14:27:29 161 | url_key: test-product-3 162 | url_path: test-product-3.html 163 | visibility: 4 164 | weight: 1 165 | weight_type: null 166 | category_ids: 167 | - 3 168 | -------------------------------------------------------------------------------- /src/app/code/community/Meanbee/AutoCategories/Test/Model/Cron.php: -------------------------------------------------------------------------------- 1 | getModelMock('meanbee_autocategories/auto_category_abstract', array('maintain'), true); 11 | 12 | $model 13 | ->expects($this->once()) 14 | ->method('maintain'); 15 | 16 | $this->replaceByMock('model', 'meanbee_autocategories/auto_category_abstract', $model); 17 | 18 | Mage::getModel('meanbee_autocategories/cron')->maintainCategories(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/app/code/community/Meanbee/AutoCategories/Test/Model/Cron/fixtures/testMaintainCategories.yaml: -------------------------------------------------------------------------------- 1 | config: 2 | default/meanbee_autocategories/general/enabled: 1 3 | global/meanbee_autocategories: 4 | global/meanbee_autocategories/test_category/model: meanbee_autocategories/auto_category_abstract 5 | -------------------------------------------------------------------------------- /src/app/code/community/Meanbee/AutoCategories/etc/adminhtml.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | Automatic Categories 13 | 100 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/app/code/community/Meanbee/AutoCategories/etc/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 1.0.1 6 | 7 | 8 | 9 | 10 | 11 | Meanbee_AutoCategories_Model 12 | 13 | 14 | 15 | 16 | Meanbee_AutoCategories_Helper 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 0 1 * * * 25 | 26 | 27 | meanbee_autocategories/cron::maintainCategories 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 0 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /src/app/code/community/Meanbee/AutoCategories/etc/system.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | catalog 7 | 100 8 | 1 9 | 1 10 | 1 11 | 12 | 13 | 14 | 10 15 | 1 16 | 1 17 | 1 18 | 19 | 20 | 21 | select 22 | adminhtml/system_config_source_yesno 23 | 10 24 | 1 25 | 1 26 | 1 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /src/app/code/community/Meanbee/NewCategory/Helper/Config.php: -------------------------------------------------------------------------------- 1 | checkDependencies() : false; 16 | } 17 | 18 | /** 19 | * Return the id of the Magento category used for NewCategory. 20 | * 21 | * @return string 22 | */ 23 | public function getCategoryId() { 24 | return Mage::getStoreConfig(self::XML_PATH_CATEGORY_ID); 25 | } 26 | 27 | /** 28 | * Return the number of days a product should stay in the "New" category 29 | * after it is created. 30 | * 31 | * @return int 32 | */ 33 | public function getDaysNew() { 34 | return intval(Mage::getStoreConfig(self::XML_PATH_DAYS_NEW)); 35 | } 36 | 37 | /** 38 | * Check if the dependencies required by NewCategory are enabled. 39 | * 40 | * @return bool 41 | */ 42 | protected function checkDependencies() { 43 | // Check if core module is installed 44 | if (!Mage::helper('core')->isModuleEnabled('Meanbee_AutoCategories')) { 45 | Mage::logException(new Exception("Meanbee_NewCategory requires Meanbee_AutoCategories to be installed and enabled.")); 46 | return false; 47 | } 48 | 49 | // Check if core module is enabled in system configuration 50 | if (!Mage::helper('meanbee_autocategories/config')->isEnabled()) { 51 | Mage::logException(new Exception("Meanbee_NewCategory requires Meanbee_AutoCategories to be enabled.")); 52 | return false; 53 | } 54 | 55 | return true; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/app/code/community/Meanbee/NewCategory/Helper/Data.php: -------------------------------------------------------------------------------- 1 | getConfig()->isEnabled(); 12 | } 13 | 14 | /** 15 | * Return the id of the Category model used for this auto category. 16 | * 17 | * @return int 18 | */ 19 | protected function getCategoryId() { 20 | return $this->getConfig()->getCategoryId(); 21 | } 22 | 23 | /** 24 | * Apply a filter to the given product collection to only select the 25 | * products which should be in this auto category. 26 | * 27 | * @param Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection $collection 28 | * 29 | * @return $this 30 | */ 31 | protected function applyFilter($collection) { 32 | $cutoff_date = $this->getCutoffDate()->toString('YYYY-MM-dd HH:mm:ss'); 33 | 34 | $collection->addAttributeToFilter('created_at', array('gteq' => $cutoff_date)); 35 | } 36 | 37 | /** 38 | * Return the cut-off date for products considered to be new. 39 | * 40 | * @return Zend_Date 41 | */ 42 | protected function getCutoffDate() { 43 | $date = Mage::app()->getLocale()->storeDate(Mage::app()->getStore(), null, true); 44 | $date->subDay($this->getConfig()->getDaysNew()); 45 | 46 | return $date; 47 | } 48 | 49 | /** 50 | * Return the configuration helper. 51 | * 52 | * @return Meanbee_NewCategory_Helper_Config 53 | */ 54 | protected function getConfig() { 55 | return Mage::helper('meanbee_newcategory/config'); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/app/code/community/Meanbee/NewCategory/Model/Observer.php: -------------------------------------------------------------------------------- 1 | getEvent()->getProduct(); 15 | 16 | if ($product) { 17 | Mage::getModel('meanbee_newcategory/auto_category_new')->maintain(array($product->getId())); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/app/code/community/Meanbee/NewCategory/Test/Config/Base.php: -------------------------------------------------------------------------------- 1 | assertModelAlias('meanbee_newcategory/test', 'Meanbee_NewCategory_Model_Test'); 10 | $this->assertHelperAlias('meanbee_newcategory/test', 'Meanbee_NewCategory_Helper_Test'); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/app/code/community/Meanbee/NewCategory/Test/Model/Auto/Category/New.php: -------------------------------------------------------------------------------- 1 | getLocale()->storeDate(Mage::app()->getStore(), "2014-02-27 12:00:00", true); 13 | 14 | $auto_category = $this->getModelMock('meanbee_newcategory/auto_category_new', array('getCurrentDate')); 15 | $auto_category 16 | ->expects($this->any()) 17 | ->method('getCurrentDate') 18 | ->will($this->returnValue($date)); 19 | 20 | $this->assertEquals(array(3, 4), array_keys($this->loadCategory($category_id)->getProductsPosition())); 21 | 22 | $auto_category->maintain(); 23 | 24 | $this->assertEquals(array(2, 4), array_keys($this->loadCategory($category_id)->getProductsPosition())); 25 | } 26 | 27 | protected function loadCategory($id) { 28 | return Mage::getModel('catalog/category')->load($id); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/app/code/community/Meanbee/NewCategory/Test/Model/Auto/Category/New/fixtures/testMaintain.yaml: -------------------------------------------------------------------------------- 1 | config: 2 | default/meanbee_autocategories/general/enabled: 1 3 | default/meanbee_autocategories/new_category/enabled: 1 4 | default/meanbee_autocategories/new_category/category: 3 5 | default/meanbee_autocategories/new_category/days: 15 6 | eav: 7 | catalog_category: 8 | - 9 | entity_id: 3 10 | parent_id: 2 11 | created_at: 2014-01-26 14:27:59 12 | updated_at: 2014-01-26 14:28:09 13 | path: 1/2/3 14 | position: 1 15 | level: 2 16 | children_count: 0 17 | store_id: 1 18 | all_children: null 19 | available_sort_by: 20 | children: null 21 | custom_apply_to_products: 0 22 | custom_design: 23 | custom_design_from: 0000-00-00 00:00:00 24 | custom_design_to: 0000-00-00 00:00:00 25 | custom_layout_update: 26 | custom_use_parent_settings: 0 27 | default_sort_by: 28 | description: This is a test 29 | display_mode: PRODUCTS 30 | filter_price_range: 0 31 | image: 32 | include_in_menu: 1 33 | is_active: 1 34 | is_anchor: 0 35 | landing_page: 0 36 | meta_description: 37 | meta_keywords: 38 | meta_title: 39 | name: Test Sale Category 40 | page_layout: 41 | path_in_store: null 42 | thumbnail: 43 | url_key: test-sale-category 44 | url_path: test-sale-category.html 45 | catalog_product: 46 | # Not in category, Not new 47 | - 48 | entity_id: 1 49 | attribute_set_id: 4 50 | type_id: simple 51 | cost: null 52 | created_at: 2014-01-26 14:27:29 53 | enable_googlecheckout: 1 54 | gift_message_available: 0 55 | has_options: 0 56 | image_label: null 57 | is_imported: 0 58 | is_recurring: 0 59 | links_exist: null 60 | links_purchased_separately: null 61 | links_title: null 62 | name: Test Product 63 | news_from_date: null 64 | news_to_date: null 65 | price: 100 66 | price_type: null 67 | price_view: null 68 | recurring_profile: null 69 | required_options: 0 70 | shipment_type: null 71 | short_description: Test 72 | sku: test 73 | sku_type: null 74 | small_image: no_selection 75 | small_image_label: null 76 | special_from_date: null 77 | special_price: null 78 | special_to_date: null 79 | tax_class_id: 0 80 | thumbnail: no_selection 81 | thumbnail_label: null 82 | updated_at: 2014-01-26 14:27:29 83 | url_key: test-product 84 | url_path: test-product.html 85 | visibility: 4 86 | weight: 1 87 | weight_type: null 88 | # Not in category, New 89 | - 90 | entity_id: 2 91 | attribute_set_id: 4 92 | type_id: simple 93 | cost: null 94 | created_at: 2014-02-26 14:27:29 95 | enable_googlecheckout: 1 96 | gift_message_available: 0 97 | has_options: 0 98 | image_label: null 99 | is_imported: 0 100 | is_recurring: 0 101 | links_exist: null 102 | links_purchased_separately: null 103 | links_title: null 104 | name: Test Product 2 105 | news_from_date: null 106 | news_to_date: null 107 | price: 100 108 | price_type: null 109 | price_view: null 110 | recurring_profile: null 111 | required_options: 0 112 | shipment_type: null 113 | short_description: Test 114 | sku: test2 115 | sku_type: null 116 | small_image: no_selection 117 | small_image_label: null 118 | special_from_date: null 119 | special_price: null 120 | special_to_date: null 121 | tax_class_id: 0 122 | thumbnail: no_selection 123 | thumbnail_label: null 124 | updated_at: 2014-02-26 14:27:29 125 | url_key: test-product-2 126 | url_path: test-product-2.html 127 | visibility: 4 128 | weight: 1 129 | weight_type: null 130 | # In category, Not new 131 | - 132 | entity_id: 3 133 | attribute_set_id: 4 134 | type_id: simple 135 | cost: null 136 | created_at: 2014-01-26 14:27:29 137 | enable_googlecheckout: 1 138 | gift_message_available: 0 139 | has_options: 0 140 | image_label: null 141 | is_imported: 0 142 | is_recurring: 0 143 | links_exist: null 144 | links_purchased_separately: null 145 | links_title: null 146 | name: Test Product 3 147 | news_from_date: null 148 | news_to_date: null 149 | price: 100 150 | price_type: null 151 | price_view: null 152 | recurring_profile: null 153 | required_options: 0 154 | shipment_type: null 155 | short_description: Test 156 | sku: test3 157 | sku_type: null 158 | small_image: no_selection 159 | small_image_label: null 160 | special_from_date: null 161 | special_price: null 162 | special_to_date: null 163 | tax_class_id: 0 164 | thumbnail: no_selection 165 | thumbnail_label: null 166 | updated_at: 2014-01-26 14:27:29 167 | url_key: test-product-3 168 | url_path: test-product-3.html 169 | visibility: 4 170 | weight: 1 171 | weight_type: null 172 | category_ids: 173 | - 3 174 | # In category, New 175 | - 176 | entity_id: 4 177 | attribute_set_id: 4 178 | type_id: simple 179 | cost: null 180 | created_at: 2014-02-26 14:27:29 181 | enable_googlecheckout: 1 182 | gift_message_available: 0 183 | has_options: 0 184 | image_label: null 185 | is_imported: 0 186 | is_recurring: 0 187 | links_exist: null 188 | links_purchased_separately: null 189 | links_title: null 190 | name: Test Product 4 191 | news_from_date: null 192 | news_to_date: null 193 | price: 100 194 | price_type: null 195 | price_view: null 196 | recurring_profile: null 197 | required_options: 0 198 | shipment_type: null 199 | short_description: Test 200 | sku: test4 201 | sku_type: null 202 | small_image: no_selection 203 | small_image_label: null 204 | special_from_date: null 205 | special_price: null 206 | special_to_date: null 207 | tax_class_id: 0 208 | thumbnail: no_selection 209 | thumbnail_label: null 210 | updated_at: 2014-02-26 14:27:29 211 | url_key: test-product-4 212 | url_path: test-product-4.html 213 | visibility: 4 214 | weight: 1 215 | weight_type: null 216 | category_ids: 217 | - 3 218 | -------------------------------------------------------------------------------- /src/app/code/community/Meanbee/NewCategory/Test/Model/Observer.php: -------------------------------------------------------------------------------- 1 | getCollection()->delete(); 8 | 9 | parent::tearDown(); 10 | } 11 | 12 | /** 13 | * @test 14 | * @loadFixture 15 | * @dataProvider dataProvider 16 | */ 17 | public function testObserveNewProduct($product_data) { 18 | $product = Mage::getModel('catalog/product')->setData($product_data); 19 | try { 20 | $product->save(); 21 | } catch (Exception $e) { 22 | Mage::throwException("Failed to save product: " . $e->getMessage()); 23 | } 24 | 25 | $product = Mage::getModel('catalog/product')->load($product->getId()); 26 | 27 | $this->assertContains(3, $product->getCategoryIds()); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/app/code/community/Meanbee/NewCategory/Test/Model/Observer/fixtures/testObserveNewProduct.yaml: -------------------------------------------------------------------------------- 1 | config: 2 | default/meanbee_autocategories/general/enabled: 1 3 | default/meanbee_autocategories/new_category/enabled: 1 4 | default/meanbee_autocategories/new_category/category: 3 5 | default/meanbee_autocategories/new_category/days: 15 6 | eav: 7 | catalog_category: 8 | - 9 | entity_id: 3 10 | parent_id: 2 11 | created_at: 2014-01-26 14:27:59 12 | updated_at: 2014-01-26 14:28:09 13 | path: 1/2/3 14 | position: 1 15 | level: 2 16 | children_count: 0 17 | store_id: 1 18 | all_children: null 19 | available_sort_by: 20 | children: null 21 | custom_apply_to_products: 0 22 | custom_design: 23 | custom_design_from: 0000-00-00 00:00:00 24 | custom_design_to: 0000-00-00 00:00:00 25 | custom_layout_update: 26 | custom_use_parent_settings: 0 27 | default_sort_by: 28 | description: This is a test 29 | display_mode: PRODUCTS 30 | filter_price_range: 0 31 | image: 32 | include_in_menu: 1 33 | is_active: 1 34 | is_anchor: 0 35 | landing_page: 0 36 | meta_description: 37 | meta_keywords: 38 | meta_title: 39 | name: Test Sale Category 40 | page_layout: 41 | path_in_store: null 42 | thumbnail: 43 | url_key: test-sale-category 44 | url_path: test-sale-category.html 45 | -------------------------------------------------------------------------------- /src/app/code/community/Meanbee/NewCategory/Test/Model/Observer/providers/testObserveNewProduct.yaml: -------------------------------------------------------------------------------- 1 | - 2 | - 3 | attribute_set_id: 4 4 | type_id: simple 5 | sku: test 6 | name: Test product 7 | description: Test product 8 | short_description: Test product 9 | price: 29.99 10 | weight: 1 11 | visibility: 4 12 | status: 1 13 | tax_class_id: 0 14 | stock_data: 15 | is_in_stock: 1 16 | qty: 9999 17 | -------------------------------------------------------------------------------- /src/app/code/community/Meanbee/NewCategory/etc/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 1.0.0 6 | 7 | 8 | 9 | 10 | 11 | Meanbee_NewCategory_Model 12 | 13 | 14 | 15 | 16 | Meanbee_NewCategory_Helper 17 | 18 | 19 | 20 | 21 | 22 | 23 | singleton 24 | meanbee_newcategory/observer 25 | maintainProduct 26 | 27 | 28 | 29 | 30 | 31 | 32 | meanbee_newcategory/auto_category_new 33 | 34 | 35 | 36 | 37 | 38 | 39 | 0 40 | 14 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /src/app/code/community/Meanbee/NewCategory/etc/system.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 60 9 | 1 10 | 1 11 | 1 12 | 13 | 14 | 15 | select 16 | adminhtml/system_config_source_yesno 17 | 10 18 | 1 19 | 1 20 | 1 21 | 22 | 23 | 24 | 25 | select 26 | meanbee_autocategories/system_config_source_category 27 | 20 28 | 1 29 | 1 30 | 1 31 | 32 | 33 | 34 | 35 | text 36 | 30 37 | 1 38 | 1 39 | 1 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /src/app/code/community/Meanbee/SaleCategory/Helper/Config.php: -------------------------------------------------------------------------------- 1 | checkDependencies() : false; 15 | } 16 | 17 | /** 18 | * Return the id of the Magento category used for SaleCategory. 19 | * 20 | * @return string 21 | */ 22 | public function getCategoryId() { 23 | return Mage::getStoreConfig(self::XML_PATH_CATEGORY_ID); 24 | } 25 | 26 | /** 27 | * Check if the dependencies required by SaleCategory are enabled. 28 | * 29 | * @return bool 30 | */ 31 | protected function checkDependencies() { 32 | // Check if core module is installed 33 | if (!Mage::helper('core')->isModuleEnabled('Meanbee_AutoCategories')) { 34 | Mage::logException(new Exception("Meanbee_SaleCategory requires Meanbee_AutoCategories to be installed and enabled.")); 35 | return false; 36 | } 37 | 38 | // Check if core module is enabled in system configuration 39 | if (!Mage::helper('meanbee_autocategories/config')->isEnabled()) { 40 | Mage::logException(new Exception("Meanbee_SaleCategory requires Meanbee_AutoCategories to be enabled.")); 41 | return false; 42 | } 43 | 44 | return true; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/app/code/community/Meanbee/SaleCategory/Helper/Data.php: -------------------------------------------------------------------------------- 1 | isEnabled(); 7 | } 8 | 9 | protected function getCategoryId() { 10 | return Mage::helper('meanbee_salecategory/config')->getCategoryId(); 11 | } 12 | 13 | protected function applyFilter($collection) { 14 | $now = $this->getCurrentDate()->toString('YYYY-MM-dd HH:mm:ss'); 15 | 16 | $collection 17 | ->addAttributeToFilter("price", array("notnull" => true)) 18 | ->addAttributeToFilter("special_price", array("notnull" => true)) 19 | ->addAttributeToFilter("special_price", array("lt" => new Zend_Db_Expr("at_price.value"))) 20 | ->addAttributeToFilter("special_from_date", array( 21 | array("null" => true), 22 | array("lteq" => $now) 23 | ), "left") 24 | ->addAttributeToFilter("special_to_date", array( 25 | array("null" => true), 26 | array("gteq" => $now) 27 | ), "left"); 28 | 29 | return $this; 30 | } 31 | 32 | /** 33 | * Return the current date. 34 | * 35 | * @return Zend_Date 36 | */ 37 | protected function getCurrentDate() { 38 | return Mage::app()->getLocale()->storeDate(Mage::app()->getStore(), null, true); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/app/code/community/Meanbee/SaleCategory/Model/Observer.php: -------------------------------------------------------------------------------- 1 | getEvent()->getProduct(); 14 | 15 | if ($product) { 16 | Mage::getModel('meanbee_salecategory/auto_category_sale')->maintain(array($product->getId())); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/app/code/community/Meanbee/SaleCategory/Test/Config/Base.php: -------------------------------------------------------------------------------- 1 | assertModelAlias('meanbee_salecategory/test', 'Meanbee_SaleCategory_Model_Test'); 10 | $this->assertHelperAlias('meanbee_salecategory/test', 'Meanbee_SaleCategory_Helper_Test'); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/app/code/community/Meanbee/SaleCategory/Test/Model/Auto/Category/Sale.php: -------------------------------------------------------------------------------- 1 | getLocale()->storeDate(Mage::app()->getStore(), "2014-02-26 12:00:00", true); 13 | 14 | $auto_category = $this->getModelMock('meanbee_salecategory/auto_category_sale', array('getCurrentDate')); 15 | $auto_category 16 | ->expects($this->any()) 17 | ->method('getCurrentDate') 18 | ->will($this->returnValue($date)); 19 | 20 | $this->assertEquals(array(2, 5, 6), array_keys($this->loadCategory($category_id)->getProductsPosition())); 21 | 22 | $auto_category->maintain(); 23 | 24 | $this->assertEquals(array(4, 6), array_keys($this->loadCategory($category_id)->getProductsPosition())); 25 | } 26 | 27 | protected function loadCategory($id) { 28 | return Mage::getModel('catalog/category')->load($id); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/app/code/community/Meanbee/SaleCategory/Test/Model/Auto/Category/Sale/fixtures/testMaintain.yaml: -------------------------------------------------------------------------------- 1 | config: 2 | default/meanbee_autocategories/general/enabled: 1 3 | default/meanbee_autocategories/sale_category/enabled: 1 4 | default/meanbee_autocategories/sale_category/category: 3 5 | eav: 6 | catalog_category: 7 | - 8 | entity_id: 3 9 | parent_id: 2 10 | created_at: 2014-02-26 14:27:59 11 | updated_at: 2014-02-26 14:28:09 12 | path: 1/2/3 13 | position: 1 14 | level: 2 15 | children_count: 0 16 | store_id: 1 17 | all_children: null 18 | available_sort_by: 19 | children: null 20 | custom_apply_to_products: 0 21 | custom_design: 22 | custom_design_from: 0000-00-00 00:00:00 23 | custom_design_to: 0000-00-00 00:00:00 24 | custom_layout_update: 25 | custom_use_parent_settings: 0 26 | default_sort_by: 27 | description: This is a test 28 | display_mode: PRODUCTS 29 | filter_price_range: 0 30 | image: 31 | include_in_menu: 1 32 | is_active: 1 33 | is_anchor: 0 34 | landing_page: 0 35 | meta_description: 36 | meta_keywords: 37 | meta_title: 38 | name: Test Sale Category 39 | page_layout: 40 | path_in_store: null 41 | thumbnail: 42 | url_key: test-sale-category 43 | url_path: test-sale-category.html 44 | catalog_product: 45 | # Not in category, Doesn't have special price, Doesn't match filter 46 | - 47 | entity_id: 1 48 | attribute_set_id: 4 49 | type_id: simple 50 | cost: null 51 | created_at: 2014-02-26 14:27:29 52 | enable_googlecheckout: 1 53 | gift_message_available: 0 54 | has_options: 0 55 | image_label: null 56 | is_imported: 0 57 | is_recurring: 0 58 | links_exist: null 59 | links_purchased_separately: null 60 | links_title: null 61 | name: Test Product 62 | news_from_date: null 63 | news_to_date: null 64 | price: 100 65 | price_type: null 66 | price_view: null 67 | recurring_profile: null 68 | required_options: 0 69 | shipment_type: null 70 | short_description: Test 71 | sku: test 72 | sku_type: null 73 | small_image: no_selection 74 | small_image_label: null 75 | special_from_date: null 76 | special_price: null 77 | special_to_date: null 78 | tax_class_id: 0 79 | thumbnail: no_selection 80 | thumbnail_label: null 81 | updated_at: 2014-02-26 14:27:29 82 | url_key: test-product 83 | url_path: test-product.html 84 | visibility: 4 85 | weight: 1 86 | weight_type: null 87 | # In category, Doesn't have special price, Doesn't match filter 88 | - 89 | entity_id: 2 90 | attribute_set_id: 4 91 | type_id: simple 92 | cost: null 93 | created_at: 2014-02-26 14:27:29 94 | enable_googlecheckout: 1 95 | gift_message_available: 0 96 | has_options: 0 97 | image_label: null 98 | is_imported: 0 99 | is_recurring: 0 100 | links_exist: null 101 | links_purchased_separately: null 102 | links_title: null 103 | name: Test Product 2 104 | news_from_date: null 105 | news_to_date: null 106 | price: 100 107 | price_type: null 108 | price_view: null 109 | recurring_profile: null 110 | required_options: 0 111 | shipment_type: null 112 | short_description: Test 113 | sku: test2 114 | sku_type: null 115 | small_image: no_selection 116 | small_image_label: null 117 | special_from_date: null 118 | special_price: null 119 | special_to_date: null 120 | tax_class_id: 0 121 | thumbnail: no_selection 122 | thumbnail_label: null 123 | updated_at: 2014-02-26 14:27:29 124 | url_key: test-product-2 125 | url_path: test-product-2.html 126 | visibility: 4 127 | weight: 1 128 | weight_type: null 129 | category_ids: 130 | - 3 131 | # Not in category, Has special price, Doesn't match filter 132 | - 133 | entity_id: 3 134 | attribute_set_id: 4 135 | type_id: simple 136 | cost: null 137 | created_at: 2014-02-26 14:27:29 138 | enable_googlecheckout: 1 139 | gift_message_available: 0 140 | has_options: 0 141 | image_label: null 142 | is_imported: 0 143 | is_recurring: 0 144 | links_exist: null 145 | links_purchased_separately: null 146 | links_title: null 147 | name: Test Product 3 148 | news_from_date: null 149 | news_to_date: null 150 | price: 100 151 | price_type: null 152 | price_view: null 153 | recurring_profile: null 154 | required_options: 0 155 | shipment_type: null 156 | short_description: Test 157 | sku: test3 158 | sku_type: null 159 | small_image: no_selection 160 | small_image_label: null 161 | special_from_date: 2014-02-20 09:00:00 162 | special_price: 50 163 | special_to_date: 2014-02-25 09:00:00 164 | tax_class_id: 0 165 | thumbnail: no_selection 166 | thumbnail_label: null 167 | updated_at: 2014-02-26 14:27:29 168 | url_key: test-product-3 169 | url_path: test-product-3.html 170 | visibility: 4 171 | weight: 1 172 | weight_type: null 173 | # Not in category, Has special price, Matches filter 174 | - 175 | entity_id: 4 176 | attribute_set_id: 4 177 | type_id: simple 178 | cost: null 179 | created_at: 2014-02-26 14:27:29 180 | enable_googlecheckout: 1 181 | gift_message_available: 0 182 | has_options: 0 183 | image_label: null 184 | is_imported: 0 185 | is_recurring: 0 186 | links_exist: null 187 | links_purchased_separately: null 188 | links_title: null 189 | name: Test Product 4 190 | news_from_date: null 191 | news_to_date: null 192 | price: 100 193 | price_type: null 194 | price_view: null 195 | recurring_profile: null 196 | required_options: 0 197 | shipment_type: null 198 | short_description: Test 199 | sku: test4 200 | sku_type: null 201 | small_image: no_selection 202 | small_image_label: null 203 | special_from_date: 2014-02-20 09:00:00 204 | special_price: 50 205 | special_to_date: 2014-02-27 09:00:00 206 | tax_class_id: 0 207 | thumbnail: no_selection 208 | thumbnail_label: null 209 | updated_at: 2014-02-26 14:27:29 210 | url_key: test-product-4 211 | url_path: test-product-4.html 212 | visibility: 4 213 | weight: 1 214 | weight_type: null 215 | # In category, Has special price, Doesn't match filter 216 | - 217 | entity_id: 5 218 | attribute_set_id: 4 219 | type_id: simple 220 | cost: null 221 | created_at: 2014-02-26 14:27:29 222 | enable_googlecheckout: 1 223 | gift_message_available: 0 224 | has_options: 0 225 | image_label: null 226 | is_imported: 0 227 | is_recurring: 0 228 | links_exist: null 229 | links_purchased_separately: null 230 | links_title: null 231 | name: Test Product 5 232 | news_from_date: null 233 | news_to_date: null 234 | price: 100 235 | price_type: null 236 | price_view: null 237 | recurring_profile: null 238 | required_options: 0 239 | shipment_type: null 240 | short_description: Test 241 | sku: test5 242 | sku_type: null 243 | small_image: no_selection 244 | small_image_label: null 245 | special_from_date: 2014-02-20 09:00:00 246 | special_price: 50 247 | special_to_date: 2014-02-25 09:00:00 248 | tax_class_id: 0 249 | thumbnail: no_selection 250 | thumbnail_label: null 251 | updated_at: 2014-02-26 14:27:29 252 | url_key: test-product-5 253 | url_path: test-product-5.html 254 | visibility: 4 255 | weight: 1 256 | weight_type: null 257 | category_ids: 258 | - 3 259 | # In category, Has special price, Matches filter 260 | - 261 | entity_id: 6 262 | attribute_set_id: 4 263 | type_id: simple 264 | cost: null 265 | created_at: 2014-02-26 14:27:29 266 | enable_googlecheckout: 1 267 | gift_message_available: 0 268 | has_options: 0 269 | image_label: null 270 | is_imported: 0 271 | is_recurring: 0 272 | links_exist: null 273 | links_purchased_separately: null 274 | links_title: null 275 | name: Test Product 6 276 | news_from_date: null 277 | news_to_date: null 278 | price: 100 279 | price_type: null 280 | price_view: null 281 | recurring_profile: null 282 | required_options: 0 283 | shipment_type: null 284 | short_description: Test 285 | sku: test6 286 | sku_type: null 287 | small_image: no_selection 288 | small_image_label: null 289 | special_from_date: 2014-02-20 09:00:00 290 | special_price: 50 291 | special_to_date: 2014-02-27 09:00:00 292 | tax_class_id: 0 293 | thumbnail: no_selection 294 | thumbnail_label: null 295 | updated_at: 2014-02-26 14:27:29 296 | url_key: test-product-6 297 | url_path: test-product-6.html 298 | visibility: 4 299 | weight: 1 300 | weight_type: null 301 | category_ids: 302 | - 3 303 | -------------------------------------------------------------------------------- /src/app/code/community/Meanbee/SaleCategory/etc/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 1.0.1 6 | 7 | 8 | 9 | 10 | 11 | Meanbee_SaleCategory_Model 12 | 13 | 14 | 15 | 16 | Meanbee_SaleCategory_Helper 17 | 18 | 19 | 20 | 21 | 22 | 23 | singleton 24 | Meanbee_SaleCategory_Model_Observer 25 | maintainProduct 26 | 27 | 28 | 29 | 30 | 31 | 32 | meanbee_salecategory/auto_category_sale 33 | 34 | 35 | 36 | 37 | 38 | 39 | 0 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /src/app/code/community/Meanbee/SaleCategory/etc/system.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 50 9 | 1 10 | 1 11 | 1 12 | 13 | 14 | 15 | select 16 | adminhtml/system_config_source_yesno 17 | 10 18 | 1 19 | 1 20 | 1 21 | 22 | 23 | 24 | 25 | select 26 | meanbee_autocategories/system_config_source_category 27 | 20 28 | 1 29 | 1 30 | 1 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /src/app/etc/modules/Meanbee_AutoCategories.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | true 6 | community 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/app/etc/modules/Meanbee_NewCategory.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | true 6 | community 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/app/etc/modules/Meanbee_SaleCategory.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | true 6 | community 7 | 8 | 9 | 10 | --------------------------------------------------------------------------------