Automatic_Sale_Category - Version 1.2.0

Version Notes

This extension will automatically add/remove products with special price into a Sale or Offer category according to the date specified.

Added functionality to support more attributes and categories.

Fixed bug in date comparison.
Supports:
MultiStore
Product import
Features:
Mail Notification
Cron Job

Download this release

Release Info

Developer Manu Jose
Extension Automatic_Sale_Category
Version 1.2.0
Comparing to
See all releases


Code changes from version 1.0.0 to 1.2.0

app/code/community/Manu/Saleproducts/Model/Category.php CHANGED
@@ -8,24 +8,22 @@
8
  */
9
  class Manu_Saleproducts_Model_Category {
10
 
11
- public function getCategories()
12
- {
13
- $categoryOption = array();
14
- $categories = Mage::getModel('catalog/category')->getCollection()
15
- ->addAttributeToSelect('name')
16
- ->addAttributeToFilter('level', array('eq' => '2'))
17
- ->load();
18
- foreach ($categories as $cat):
19
- $temp = array('value' => $cat->getName(), 'label' => $cat->getName().' ( Root Category : '.$cat->getParentCategory()->getName().' ) ' );
20
- array_push($categoryOption, $temp);
21
- endforeach;
22
- return $categoryOption;
23
- }
24
 
25
- public function toOptionArray()
26
- {
27
- return ($this->getCategories());
28
- }
29
 
30
  }
31
  ?>
8
  */
9
  class Manu_Saleproducts_Model_Category {
10
 
11
+ public function getCategories() {
12
+ $categoryOption = array();
13
+ $categories = Mage::getModel('catalog/category')->getCollection()
14
+ ->addAttributeToSelect('name')
15
+ ->addAttributeToFilter('level', array('eq' => '2'))
16
+ ->load();
17
+ foreach ($categories as $cat):
18
+ $temp = array('value' => $cat->getId(), 'label' => $cat->getName() . ' ( Root Category : ' . $cat->getParentCategory()->getName() . ' ) ');
19
+ array_push($categoryOption, $temp);
20
+ endforeach;
21
+ return $categoryOption;
22
+ }
 
23
 
24
+ public function toOptionArray() {
25
+ return ($this->getCategories());
26
+ }
 
27
 
28
  }
29
  ?>
app/code/community/Manu/Saleproducts/Model/Observer.php CHANGED
@@ -14,125 +14,161 @@ class Manu_Saleproducts_Model_Observer {
14
  * Notification:send mail to the store owner with list of removed products.
15
  *
16
  */
 
17
 
18
- public function removeOfferProducts()
19
- {
20
-
21
- $mailContent = array();
22
- $sales;
23
- $i = 0;
24
- $categories = Mage::getModel('catalog/category')->getCollection()
25
- ->addAttributeToFilter('name', Mage::getStoreConfig('sale_category/general/offer_category'))
26
- ->addAttributeToSelect('id')
27
- ->load();
28
- foreach ($categories as $product)
29
- { //loop for getting products
30
- $sales[$i] = $product->getId();
31
- $i++;
32
- }
33
- $categoryCollection = Mage::getModel('catalog/category')->getCollection()
34
- ->addAttributeToSelect('id')
35
- ->load();
36
- foreach ($categoryCollection as $cat):
37
-
38
- $currentCategoryId = $cat->getId();
39
- if (in_array($currentCategoryId, $sales))
40
- {
41
- $todayDate = date('m/d/y');
42
- $yesterday = mktime(0, 0, 0, date('m'), date('d') - 1, date('y'));
43
- $yesterdayDate = date('m/d/y', $yesterday);
44
- $catagoryModel = Mage::getModel('catalog/category')->load($currentCategoryId);
45
- $productCollection = Mage::getResourceModel('catalog/product_collection')->addAttributeToSelect('name')->addCategoryFilter($catagoryModel);
46
- $productCollection->addAttributeToFilter('special_to_date', array('date' => true, 'to' => $yesterdayDate));
47
- $currentStoreID = Mage::app()->getStore()->getId();
48
- Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
49
- foreach ($productCollection as $currentProduct)
50
- {
51
- array_push($mailContent, $currentProduct->getName());
52
- $categoryIds = $currentProduct->getCategoryIds();
53
- $categoryIds = str_replace($currentCategoryId, "", $categoryIds);
54
- $currentProduct->setCategoryIds($categoryIds);
55
- $currentProduct->save();
56
- }
57
- Mage::app()->setCurrentStore($currentStoreID);
58
- }
59
-
60
- endforeach;
61
- if (Mage::getStoreConfig('sale_category/general/offer_mail'))
62
- {
63
- $newContent = "Following products are removed from Sale/Offer Category due to the end of special price date.\r\n
64
- This mail was generated by a cron job.<br/> You can turn of this mail notification in system->config->catalog->Sale / Offer";
65
- $headers = "MIME-Version: 1.0" . "\r\n";
66
- $headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
67
- $headers .= 'From: <' . Mage::getStoreConfig('general/store_information/name') . '@magento.com>';
68
- $mailContent = array_unique($mailContent);
69
- foreach ($mailContent as $value)
70
- {
71
- $newContent = $newContent . "\r\n" . $value;
72
- }
73
- mail(Mage::getStoreConfig('trans_email/ident_general/email'), "Removed Products", $newContent, $headers);
74
- }
75
- $this->saleProductsImport(TRUE);
 
 
 
 
 
 
 
 
 
 
 
 
 
76
  }
77
 
78
- public function saleProductsImport($cron=null)
79
- {
80
- if (Mage::getStoreConfig('sale_category/general/offer_cron') || isset($cron))
81
- {
82
- $mailContent = array();
83
- $categories = Mage::getModel('catalog/category')->getCollection()
84
- ->addAttributeToSelect('id')
85
- ->addAttributeToSelect('name')
86
- ->addAttributeToFilter('is_active', array('eq' => true))
87
- ->addAttributeToFilter('level', array('eq' => '1'))
88
- ->load();
89
- echo '<pre/>';
90
- foreach ($categories as $value)
91
- {
92
- $categoriesColl = Mage::getModel('catalog/category')->getCollection()
93
- ->addAttributeToFilter('name', Mage::getStoreConfig('sale_category/general/offer_category'))
94
- ->addAttributeToSelect('id')
95
- ->addAttributeToSelect('name')
96
- ->load($value['id']);
97
- }
98
- foreach ($categoriesColl as $value)
99
- {
100
- echo $value['entity_id'];
101
- $todayDate = date('m/d/y');
102
- $productCollection = Mage::getResourceModel('catalog/product_collection')->addAttributeToSelect('name');
103
- $productCollection->addAttributeToFilter('special_from_date', array('date' => true, 'from' => $todayDate));
104
- foreach ($productCollection as $currentProduct)
105
- {
106
-
107
- $categoryIds = $currentProduct->getCategoryIds();
108
- if (!in_array($value['entity_id'], $categoryIds))
109
- {
110
- echo "already in array";
111
- array_push($categoryIds, $value['entity_id']);
112
- array_push($mailContent, $currentProduct->getName());
113
- }
114
- $currentProduct->setCategoryIds($categoryIds);
115
- $currentProduct->save();
116
- print_r($categoryIds);
117
- echo $currentProduct['name'];
118
- }
119
- echo '<br/>hiiii<br/>';
120
- }
121
- if (Mage::getStoreConfig('sale_category/general/offer_mail'))
122
- {
123
- $newContent = "Following products are Added to Sale/Offer Category by a cron job.<br/> You can turn of this mail notification in system->config->catalog->Sale / Offer\r\n";
124
- $headers = "MIME-Version: 1.0" . "\r\n";
125
- $headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
126
- $headers .= 'From: <' . Mage::getStoreConfig('general/store_information/name') . '@magento.com>';
127
- $mailContent = array_unique($mailContent);
128
- foreach ($mailContent as $value)
129
- {
130
- $newContent = $newContent . "\r\n" . $value;
131
- }
132
- mail(Mage::getStoreConfig('trans_email/ident_general/email'), "Product Added to offer Category", $newContent, $headers);
133
- }
134
  }
 
 
 
135
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
136
 
137
  }
138
 
14
  * Notification:send mail to the store owner with list of removed products.
15
  *
16
  */
17
+ public function addRemoveProducts() {
18
 
19
+ //date calculation
20
+ $email_content = array();
21
+ $current_date = date("Y-m-d 00:00:00", Mage::getModel('core/date')->timestamp(time()));
22
+ $yesterday_date = date("Y-m-d 00:00:00", Mage::getModel('core/date')->timestamp(time() - 60 * 60 * 24));
23
+
24
+
25
+ //case 1
26
+ if (Mage::getStoreConfig('sale_category/general/t_shirt_of_day_enable')) {
27
+
28
+ //category
29
+ $catid = Mage::getStoreConfig('sale_category/general/t_shirt_of_day');
30
+ $attr_name = 'special_to_date';
31
+ $email_content['shirt']['removed'] = $this->removeProduct($catid, $yesterday_date, $attr_name);
32
+ $attr_name = 'special_from_date';
33
+ $email_content['shirt']['added'] = $this->addProduct($catid, $current_date, $attr_name);
34
+ }
35
+
36
+ //case 2
37
+ if (Mage::getStoreConfig('sale_category/general/after_hour_enable')) {
38
+
39
+ //category
40
+ $catid = Mage::getStoreConfig('sale_category/general/after_hour');
41
+ $attr_name = 'afterhours_to_date';
42
+ $email_content['after_hour']['removed'] = $this->removeProduct($catid, $yesterday_date, $attr_name);
43
+ $attr_name = 'afterhours_from_date';
44
+ $email_content['after_hour']['added'] = $this->addProduct($catid, $current_date, $attr_name);
45
+ }
46
+
47
+ //case 3
48
+ if (Mage::getStoreConfig('sale_category/general/gallery_enable')) {
49
+
50
+ //category
51
+ $catid = Mage::getStoreConfig('sale_category/general/gallery');
52
+ $attr_name = 'gallery_to_date';
53
+ $email_content['gallery']['removed'] = $this->removeProduct($catid, $yesterday_date, $attr_name);
54
+ $attr_name = 'gallery_from_date';
55
+ $email_content['gallery']['added'] = $this->addProduct($catid, $current_date, $attr_name);
56
+ }
57
+ if (Mage::getStoreConfig('sale_category/general/offer_mail')) {
58
+ $newContent = "Hi,<br/> These are the products Added or Removed through Auto Sale Extension";
59
+ $headers = "MIME-Version: 1.0" . "\r\n";
60
+ $headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
61
+ $headers .= 'From: <' . Mage::getStoreConfig('general/store_information/name') . '@magento.com>';
62
+
63
+ $newContent .='<br/><br/><b><u>T-Shirt of the day </u></b><br/>Added Products';
64
+ foreach ($email_content['shirt']['added'] as $prod_id => $prod_name) {
65
+ $newContent .='<br/>' . $prod_id . ' - ' . $prod_name;
66
+ }
67
+ $newContent .='<br/><br/>Removed Products';
68
+ foreach ($email_content['shirt']['removed'] as $prod_id => $prod_name) {
69
+ $newContent .='<br/>' . $prod_id . ' - ' . $prod_name;
70
+ }
71
+ $newContent .='<br/><br/><b><u>After Hour </u></b><br/>Added Products';
72
+ foreach ($email_content['after_hour']['added'] as $prod_id => $prod_name) {
73
+ $newContent .='<br/>' . $prod_id . ' - ' . $prod_name;
74
+ }
75
+ $newContent .='<br/><br/>Removed Products';
76
+ foreach ($email_content['after_hour']['removed'] as $prod_id => $prod_name) {
77
+ $newContent .='<br/>' . $prod_id . ' - ' . $prod_name;
78
+ }
79
+ $newContent .='<br/><br/><b><u>Gallery </u></b><br/>Added Products';
80
+ foreach ($email_content['gallery']['added'] as $prod_id => $prod_name) {
81
+ $newContent .='<br/>' . $prod_id . ' - ' . $prod_name;
82
+ }
83
+ $newContent .='<br/><br/>Removed Products';
84
+ foreach ($email_content['gallery']['removed'] as $prod_id => $prod_name) {
85
+ $newContent .='<br/>' . $prod_id . ' - ' . $prod_name;
86
+ }
87
+
88
+ $newContent .='<br/><br/> Thanks....<br/>';
89
+ mail(Mage::getStoreConfig('trans_email/ident_general/email'), "Product Added/Removed By Auto Sale Extension", $newContent, $headers);
90
  }
91
 
92
+ //mage::log($email_content);
93
+ }
94
+
95
+
96
+
97
+ /**
98
+ * Removes product from a category
99
+ * @param type $category_id
100
+ * @param type $yesterday_date
101
+ * @param type $attr_name
102
+ * @return type
103
+ */
104
+ public function removeProduct($category_id, $yesterday_date, $attr_name) {
105
+
106
+ $removedProducts = array();
107
+ $catagoryModel = Mage::getModel('catalog/category')->load($category_id);
108
+
109
+
110
+ //product collection
111
+ $productCollection = Mage::getResourceModel('reports/product_collection')
112
+ ->addAttributeToSelect('id')
113
+ ->addAttributeToSelect('name')
114
+ ->addCategoryFilter($catagoryModel);
115
+ $productCollection->addAttributeToFilter($attr_name, array('date' => true, 'to' => $yesterday_date));
116
+ $productCollection->load();
117
+
118
+ $currentStoreID = Mage::app()->getStore()->getId();
119
+ Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
120
+
121
+ foreach ($productCollection as $product) {
122
+ $categoryIds = $product->getCategoryIds();
123
+ if (in_array($category_id, $categoryIds)) {
124
+ if (($key = array_search($category_id, $categoryIds)) !== false) {
125
+ unset($categoryIds[$key]);
126
+ $removedProducts[$product->getId()] = $product->getName();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
127
  }
128
+ $product->setCategoryIds($categoryIds);
129
+ $product->save();
130
+ }
131
  }
132
+ Mage::app()->setCurrentStore($currentStoreID);
133
+
134
+ return $removedProducts;
135
+ }
136
+
137
+ /**
138
+ * Add products to a category
139
+ * @param type $category_id
140
+ * @param type $current_date
141
+ * @param type $attr_name
142
+ * @return type
143
+ */
144
+ public function addProduct($category_id, $current_date, $attr_name) {
145
+
146
+ $addedProducts = array();
147
+
148
+ //product collection
149
+ $productCollection = Mage::getResourceModel('reports/product_collection')
150
+ ->addAttributeToSelect('id')
151
+ ->addAttributeToSelect('name');
152
+ $productCollection->addAttributeToFilter($attr_name, array('date' => true, 'from' => $current_date));
153
+ $productCollection->load();
154
+
155
+ $currentStoreID = Mage::app()->getStore()->getId();
156
+ Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
157
+
158
+ foreach ($productCollection as $product) {
159
+ $categoryIds = $product->getCategoryIds();
160
+ if (!in_array($category_id, $categoryIds)) {
161
+ $categoryIds[] = $category_id;
162
+ $product->setCategoryIds($categoryIds);
163
+ $product->save();
164
+
165
+ $addedProducts[$product->getId()] = $product->getName();
166
+ }
167
+ }
168
+ Mage::app()->setCurrentStore($currentStoreID);
169
+
170
+ return $addedProducts;
171
+ }
172
 
173
  }
174
 
app/code/community/Manu/Saleproducts/controllers/Catalog/ProductController.php CHANGED
@@ -12,16 +12,12 @@ include_once("Mage/Adminhtml/controllers/Catalog/ProductController.php");
12
 
13
  class Manu_Saleproducts_Catalog_ProductController extends Mage_Adminhtml_Catalog_ProductController {
14
 
15
- protected function _initProductSave() {
16
- $product = $this->_initProduct();
 
17
  $productData = $this->getRequest()->getPost('product');
18
  if ($productData) {
19
- if (!isset($productData['stock_data']['use_config_manage_stock'])) {
20
- $productData['stock_data']['use_config_manage_stock'] = 0;
21
- }
22
- if (isset($productData['stock_data']['qty']) && (float) $productData['stock_data']['qty'] > self::MAX_QTY_VALUE) {
23
- $productData['stock_data']['qty'] = self::MAX_QTY_VALUE;
24
- }
25
  }
26
 
27
  /**
@@ -50,9 +46,10 @@ class Manu_Saleproducts_Catalog_ProductController extends Mage_Adminhtml_Catalog
50
  /**
51
  * Create Permanent Redirect for old URL key
52
  */
53
- if ($product->getId() && isset($productData['url_key_create_redirect'])) {
54
- // && $product->getOrigData('url_key') != $product->getData('url_key')
55
- $product->setData('save_rewrites_history', (bool) $productData['url_key_create_redirect']);
 
56
  }
57
 
58
  /**
@@ -76,7 +73,7 @@ class Manu_Saleproducts_Catalog_ProductController extends Mage_Adminhtml_Catalog
76
  }
77
  if (isset($links['crosssell']) && !$product->getCrosssellReadonly()) {
78
  $product->setCrossSellLinkData(Mage::helper('adminhtml/js')
79
- ->decodeGridSerializedInput($links['crosssell']));
80
  }
81
  if (isset($links['grouped']) && !$product->getGroupedReadonly()) {
82
  $product->setGroupedLinkData(Mage::helper('adminhtml/js')->decodeGridSerializedInput($links['grouped']));
@@ -85,54 +82,7 @@ class Manu_Saleproducts_Catalog_ProductController extends Mage_Adminhtml_Catalog
85
  /**
86
  * Initialize product categories
87
  */
88
- /**
89
- * Overriding core functionality-atomatically adds products to sale category
90
- */
91
- $datasale = $this->getRequest()->getPost();
92
  $categoryIds = $this->getRequest()->getPost('category_ids');
93
- /**
94
- * if categories are null in posted data, then retriving from model
95
- */
96
- if (null == $categoryIds) {
97
- $productId = $this->getRequest()->getParam('id');
98
- $productModel = Mage::getModel('catalog/product')->load($productId);
99
- $cats_ids = $productModel->getCategoryIds($productId);
100
- $categoryIds = implode($cats_ids, ",");
101
- }
102
- $sales= array();
103
- $i = 0;
104
- $categories = Mage::getModel('catalog/category')->getCollection()
105
- ->addAttributeToFilter('name', Mage::getStoreConfig('sale_category/general/offer_category'))
106
- ->addAttributeToSelect('id')
107
- ->load();
108
- foreach ($categories as $productcategory) {
109
- $sales[$i] = $productcategory->getId();
110
- $i++;
111
- }
112
- $todayDate = date('d/m/Y');
113
- $data = $this->getRequest()->getPost();
114
- $websiteId = $datasale['product']['website_ids'];
115
- foreach ($websiteId as $siteId) {
116
- if ($datasale['product']['special_price']) {
117
-
118
- if($data['product']['special_from_date']=="")
119
- $data['product']['special_from_date']=$todayDate;
120
- if(($data['product']['special_from_date'] <= $todayDate) && ($data['product']['special_from_date']<=$data['product']['special_to_date'] || $data['product']['special_to_date']=="") && ($data['product']['special_to_date']>=$todayDate || $data['product']['special_to_date']=="") )
121
- $categoryIds = $categoryIds . "," . $sales[$siteId - 1];
122
- else
123
- $categoryIds = str_replace($sales[$siteId - 1], "", $categoryIds);
124
-
125
-
126
- } else {
127
- $categoryIds = str_replace($sales[$siteId - 1], "", $categoryIds);
128
- }
129
- }
130
- $websiteCount = Mage::app()->getWebsites();
131
- for ($i = 1; $i <= count($websiteCount); $i++) {
132
- if (!in_array($i, $websiteId)) {
133
- $categoryIds = str_replace($sales[$i - 1], "", $categoryIds);
134
- }
135
- }
136
  if (null !== $categoryIds) {
137
  if (empty($categoryIds)) {
138
  $categoryIds = array();
@@ -144,18 +94,18 @@ class Manu_Saleproducts_Catalog_ProductController extends Mage_Adminhtml_Catalog
144
  * Initialize data for configurable product
145
  */
146
  if (($data = $this->getRequest()->getPost('configurable_products_data'))
147
- && !$product->getConfigurableReadonly()
148
  ) {
149
  $product->setConfigurableProductsData(Mage::helper('core')->jsonDecode($data));
150
  }
151
  if (($data = $this->getRequest()->getPost('configurable_attributes_data'))
152
- && !$product->getConfigurableReadonly()
153
  ) {
154
  $product->setConfigurableAttributesData(Mage::helper('core')->jsonDecode($data));
155
  }
156
 
157
  $product->setCanSaveConfigurableAttributes(
158
- (bool) $this->getRequest()->getPost('affect_configurable_product_attributes')
159
  && !$product->getConfigurableReadonly()
160
  );
161
 
@@ -167,12 +117,13 @@ class Manu_Saleproducts_Catalog_ProductController extends Mage_Adminhtml_Catalog
167
  }
168
 
169
  $product->setCanSaveCustomOptions(
170
- (bool) $this->getRequest()->getPost('affect_product_custom_options')
171
- && !$product->getOptionsReadonly()
172
  );
173
 
174
  Mage::dispatchEvent(
175
- 'catalog_product_prepare_save', array('product' => $product, 'request' => $this->getRequest())
 
176
  );
177
 
178
  return $product;
@@ -181,42 +132,17 @@ class Manu_Saleproducts_Catalog_ProductController extends Mage_Adminhtml_Catalog
181
  /**
182
  * Save product action
183
  */
184
- public function saveAction() {
 
 
 
 
 
185
 
186
- /**
187
- * Overriding core functionality-atomatically adds products to sale category
188
- */
189
- $sales= array ();
190
- $i = 0;
191
- $categories = Mage::getModel('catalog/category')->getCollection()
192
- ->addAttributeToFilter('name', Mage::getStoreConfig('sale_category/general/offer_category'))
193
- ->addAttributeToSelect('id')
194
- ->load();
195
- foreach ($categories as $product) { //loop for getting products
196
- $sales[$i] = $product->getId();
197
- $i++;
198
- }
199
- $storeId = $this->getRequest()->getParam('store');
200
- $redirectBack = $this->getRequest()->getParam('back', false);
201
- $productId = $this->getRequest()->getParam('id');
202
- $isEdit = (int) ($this->getRequest()->getParam('id') != null);
203
- $categoryId_Sale = ",";
204
- $categorySale = ",";
205
  $data = $this->getRequest()->getPost();
206
- $websiteId = $data['product']['website_ids'];
207
- foreach ($websiteId as $siteId) {
208
- if ($data['product']['special_price']) {
209
- $categorySale = $categorySale . "," . $sales[$siteId - 1] . "," . $sales[$siteId - 1];
210
- } else {
211
- $categoryId_Sale = $categoryId_Sale . "," . $sales[$siteId - 1];
212
- }
213
- }
214
-
215
- // $data['category_ids'] = $data['category_ids'] . $categorySale . $categoryId_Sale;
216
  if ($data) {
217
- if (!isset($data['product']['stock_data']['use_config_manage_stock'])) {
218
- $data['product']['stock_data']['use_config_manage_stock'] = 0;
219
- }
220
  $product = $this->_initProductSave();
221
 
222
  try {
@@ -227,12 +153,12 @@ class Manu_Saleproducts_Catalog_ProductController extends Mage_Adminhtml_Catalog
227
  * Do copying data to stores
228
  */
229
  if (isset($data['copy_to_stores'])) {
230
- foreach ($data['copy_to_stores'] as $storeTo => $storeFrom) {
231
  $newProduct = Mage::getModel('catalog/product')
232
- ->setStoreId($storeFrom)
233
- ->load($productId)
234
- ->setStoreId($storeTo)
235
- ->save();
236
  }
237
  }
238
 
@@ -241,7 +167,7 @@ class Manu_Saleproducts_Catalog_ProductController extends Mage_Adminhtml_Catalog
241
  $this->_getSession()->addSuccess($this->__('The product has been saved.'));
242
  } catch (Mage_Core_Exception $e) {
243
  $this->_getSession()->addError($e->getMessage())
244
- ->setProductData($data);
245
  $redirectBack = true;
246
  } catch (Exception $e) {
247
  Mage::logException($e);
@@ -249,20 +175,175 @@ class Manu_Saleproducts_Catalog_ProductController extends Mage_Adminhtml_Catalog
249
  $redirectBack = true;
250
  }
251
  }
252
-
 
 
 
 
253
  if ($redirectBack) {
254
  $this->_redirect('*/*/edit', array(
255
- 'id' => $productId,
256
- '_current' => true
257
  ));
258
- } elseif ($this->getRequest()->getParam('popup')) {
259
  $this->_redirect('*/*/created', array(
260
- '_current' => true,
261
- 'id' => $productId,
262
- 'edit' => $isEdit
263
  ));
264
  } else {
265
- $this->_redirect('*/*/', array('store' => $storeId));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
266
  }
267
  }
268
 
12
 
13
  class Manu_Saleproducts_Catalog_ProductController extends Mage_Adminhtml_Catalog_ProductController {
14
 
15
+ protected function _initProductSave()
16
+ {
17
+ $product = $this->_initProduct();
18
  $productData = $this->getRequest()->getPost('product');
19
  if ($productData) {
20
+ $this->_filterStockData($productData['stock_data']);
 
 
 
 
 
21
  }
22
 
23
  /**
46
  /**
47
  * Create Permanent Redirect for old URL key
48
  */
49
+ if ($product->getId() && isset($productData['url_key_create_redirect']))
50
+ // && $product->getOrigData('url_key') != $product->getData('url_key')
51
+ {
52
+ $product->setData('save_rewrites_history', (bool)$productData['url_key_create_redirect']);
53
  }
54
 
55
  /**
73
  }
74
  if (isset($links['crosssell']) && !$product->getCrosssellReadonly()) {
75
  $product->setCrossSellLinkData(Mage::helper('adminhtml/js')
76
+ ->decodeGridSerializedInput($links['crosssell']));
77
  }
78
  if (isset($links['grouped']) && !$product->getGroupedReadonly()) {
79
  $product->setGroupedLinkData(Mage::helper('adminhtml/js')->decodeGridSerializedInput($links['grouped']));
82
  /**
83
  * Initialize product categories
84
  */
 
 
 
 
85
  $categoryIds = $this->getRequest()->getPost('category_ids');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86
  if (null !== $categoryIds) {
87
  if (empty($categoryIds)) {
88
  $categoryIds = array();
94
  * Initialize data for configurable product
95
  */
96
  if (($data = $this->getRequest()->getPost('configurable_products_data'))
97
+ && !$product->getConfigurableReadonly()
98
  ) {
99
  $product->setConfigurableProductsData(Mage::helper('core')->jsonDecode($data));
100
  }
101
  if (($data = $this->getRequest()->getPost('configurable_attributes_data'))
102
+ && !$product->getConfigurableReadonly()
103
  ) {
104
  $product->setConfigurableAttributesData(Mage::helper('core')->jsonDecode($data));
105
  }
106
 
107
  $product->setCanSaveConfigurableAttributes(
108
+ (bool) $this->getRequest()->getPost('affect_configurable_product_attributes')
109
  && !$product->getConfigurableReadonly()
110
  );
111
 
117
  }
118
 
119
  $product->setCanSaveCustomOptions(
120
+ (bool)$this->getRequest()->getPost('affect_product_custom_options')
121
+ && !$product->getOptionsReadonly()
122
  );
123
 
124
  Mage::dispatchEvent(
125
+ 'catalog_product_prepare_save',
126
+ array('product' => $product, 'request' => $this->getRequest())
127
  );
128
 
129
  return $product;
132
  /**
133
  * Save product action
134
  */
135
+ public function saveAction()
136
+ {
137
+ $storeId = $this->getRequest()->getParam('store');
138
+ $redirectBack = $this->getRequest()->getParam('back', false);
139
+ $productId = $this->getRequest()->getParam('id');
140
+ $isEdit = (int)($this->getRequest()->getParam('id') != null);
141
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
142
  $data = $this->getRequest()->getPost();
 
 
 
 
 
 
 
 
 
 
143
  if ($data) {
144
+ $this->_filterStockData($data['product']['stock_data']);
145
+
 
146
  $product = $this->_initProductSave();
147
 
148
  try {
153
  * Do copying data to stores
154
  */
155
  if (isset($data['copy_to_stores'])) {
156
+ foreach ($data['copy_to_stores'] as $storeTo=>$storeFrom) {
157
  $newProduct = Mage::getModel('catalog/product')
158
+ ->setStoreId($storeFrom)
159
+ ->load($productId)
160
+ ->setStoreId($storeTo)
161
+ ->save();
162
  }
163
  }
164
 
167
  $this->_getSession()->addSuccess($this->__('The product has been saved.'));
168
  } catch (Mage_Core_Exception $e) {
169
  $this->_getSession()->addError($e->getMessage())
170
+ ->setProductData($data);
171
  $redirectBack = true;
172
  } catch (Exception $e) {
173
  Mage::logException($e);
175
  $redirectBack = true;
176
  }
177
  }
178
+
179
+ //calls a custome function
180
+ $this->autoSaleCategory($product);
181
+
182
+
183
  if ($redirectBack) {
184
  $this->_redirect('*/*/edit', array(
185
+ 'id' => $productId,
186
+ '_current'=>true
187
  ));
188
+ } elseif($this->getRequest()->getParam('popup')) {
189
  $this->_redirect('*/*/created', array(
190
+ '_current' => true,
191
+ 'id' => $productId,
192
+ 'edit' => $isEdit
193
  ));
194
  } else {
195
+ $this->_redirect('*/*/', array('store'=>$storeId));
196
+ }
197
+ }
198
+
199
+ public function autoSaleCategory($product)
200
+ {
201
+ $productId = $product->getId();
202
+ $storeId=0;//Mage::app()->getRequest()->getParam('store');
203
+ $attribute_code_tshirt_from='special_from_date';
204
+ $attribute_code_tshirt_to='special_to_date';
205
+ $attribute_code_after_from='afterhours_from_date';
206
+ $attribute_code_after_to='afterhours_to_date';
207
+ $attribute_code_gallery_from='gallery_from_date';
208
+ $attribute_code_gallery_to='gallery_to_date';
209
+ $current_date=date("Y-m-d 00:00:00", Mage::getModel('core/date')->timestamp(time()));
210
+
211
+
212
+
213
+ //case 1:T shirt of the day
214
+ if(Mage::getStoreConfig('sale_category/general/t_shirt_of_day_enable'))
215
+ {
216
+ $catid=Mage::getStoreConfig('sale_category/general/t_shirt_of_day');
217
+ $from_date=Mage::getResourceModel('catalog/product')->getAttributeRawValue($productId, $attribute_code_tshirt_from, $storeId);
218
+ $to_date=Mage::getResourceModel('catalog/product')->getAttributeRawValue($productId, $attribute_code_tshirt_to, $storeId);
219
+
220
+ if($from_date!='')
221
+ {
222
+
223
+ if($from_date <= $current_date)
224
+ {
225
+ if($to_date !='')
226
+ {
227
+ if($to_date >= $current_date)
228
+ {
229
+ $this->_autosale_add_category($product, $catid);
230
+ }
231
+ else {
232
+
233
+ $this->_autosale_remove_category($product, $catid);
234
+ }
235
+ }
236
+ else{
237
+
238
+ $this->_autosale_add_category($product, $catid);
239
+ }
240
+ }
241
+
242
+ }
243
+
244
+ }
245
+
246
+
247
+ //case 2: After hour
248
+ if(Mage::getStoreConfig('sale_category/general/after_hour_enable'))
249
+ {
250
+ $catid=Mage::getStoreConfig('sale_category/general/after_hour');
251
+ $from_date=Mage::getResourceModel('catalog/product')->getAttributeRawValue($productId, $attribute_code_after_from, $storeId);
252
+ $to_date=Mage::getResourceModel('catalog/product')->getAttributeRawValue($productId, $attribute_code_after_to, $storeId);
253
+
254
+ if($from_date!='')
255
+ {
256
+
257
+ if($from_date <= $current_date)
258
+ {
259
+ if($to_date !='')
260
+ {
261
+ if($to_date >= $current_date)
262
+ {
263
+
264
+ $this->_autosale_add_category($product, $catid);
265
+ }
266
+ else {
267
+
268
+ $this->_autosale_remove_category($product, $catid);
269
+ }
270
+ }
271
+ else{
272
+
273
+ $this->_autosale_add_category($product, $catid);
274
+ }
275
+ }
276
+
277
+ }
278
+
279
+
280
+
281
+ }
282
+
283
+
284
+ //case 3:Gallery Category
285
+ if(Mage::getStoreConfig('sale_category/general/gallery_enable'))
286
+ {
287
+ $catid=Mage::getStoreConfig('sale_category/general/gallery');
288
+ $from_date=Mage::getResourceModel('catalog/product')->getAttributeRawValue($productId, $attribute_code_gallery_from, $storeId);
289
+ $to_date=Mage::getResourceModel('catalog/product')->getAttributeRawValue($productId, $attribute_code_gallery_to, $storeId);
290
+
291
+ if($from_date!='')
292
+ {
293
+
294
+ if($from_date <= $current_date)
295
+ {
296
+ if($to_date !='')
297
+ {
298
+ if($to_date >= $current_date)
299
+ {
300
+
301
+ $this->_autosale_add_category($product, $catid);
302
+ }
303
+ else {
304
+
305
+ $this->_autosale_remove_category($product, $catid);
306
+ }
307
+ }
308
+ else{
309
+
310
+ $this->_autosale_add_category($product, $catid);
311
+ }
312
+ }
313
+
314
+ }
315
+
316
+
317
+ }
318
+
319
+ }
320
+
321
+ private function _autosale_add_category($product,$cat_id='')
322
+ {
323
+ if($cat_id !='')
324
+ {
325
+ $categoryIds = $product->getCategoryIds();
326
+ if(!in_array($cat_id, $categoryIds))
327
+ {
328
+ $categoryIds[]=$cat_id;
329
+ $product->setCategoryIds($categoryIds);
330
+ $product->save();
331
+ }
332
+ }
333
+ }
334
+ private function _autosale_remove_category($product,$cat_id='')
335
+ {
336
+ if($cat_id !='')
337
+ {
338
+ $categoryIds = $product->getCategoryIds();
339
+ if(in_array($cat_id, $categoryIds))
340
+ {
341
+ if (($key = array_search($cat_id, $categoryIds)) !== false) {
342
+ unset($categoryIds[$key]);
343
+ }
344
+ $product->setCategoryIds($categoryIds);
345
+ $product->save();
346
+ }
347
  }
348
  }
349
 
app/code/community/Manu/Saleproducts/etc/config.xml CHANGED
@@ -35,19 +35,7 @@
35
  </adminhtml>
36
  </routers>
37
  </admin>
38
- <global>
39
- <events>
40
- <catalog_product_import_finish_before>
41
- <observers>
42
- <Manu_Saleproducts>
43
- <type>singleton</type>
44
- <class>Manu_Saleproducts_Model_Observer</class>
45
- <method>saleProductsImport</method>
46
- </Manu_Saleproducts>
47
- </observers>
48
- </catalog_product_import_finish_before>
49
-
50
- </events>
51
  <models>
52
 
53
  <Saleproducts>
@@ -85,8 +73,8 @@
85
  <crontab>
86
  <jobs>
87
  <remove_offer_products>
88
- <schedule><cron_expr>0 19 * * *</cron_expr></schedule>
89
- <run><model>Saleproducts/observer::removeOfferProducts</model></run>
90
  </remove_offer_products>
91
  </jobs>
92
  </crontab>
35
  </adminhtml>
36
  </routers>
37
  </admin>
38
+ <global>
 
 
 
 
 
 
 
 
 
 
 
 
39
  <models>
40
 
41
  <Saleproducts>
73
  <crontab>
74
  <jobs>
75
  <remove_offer_products>
76
+ <schedule><cron_expr>1 0 * * *</cron_expr></schedule>
77
+ <run><model>Saleproducts/observer::addRemoveProducts</model></run>
78
  </remove_offer_products>
79
  </jobs>
80
  </crontab>
app/code/community/Manu/Saleproducts/etc/system.xml CHANGED
@@ -18,41 +18,81 @@
18
  <show_in_default>1</show_in_default>
19
  <show_in_website>1</show_in_website>
20
  <show_in_store>1</show_in_store>
21
- <fields>
22
- <offer_category translate="label">
23
- <label>Sale/Offer Category</label>
24
- <comment><![CDATA[This category should be in category list.Give the name as it in the product category.
25
- Product with Special price in other categories will automatically added to this category.
26
- (Please consider the letter case.)]]></comment>
27
  <frontend_type>select</frontend_type>
28
- <source_model>Saleproducts/category</source_model>
29
  <sort_order>3</sort_order>
30
  <show_in_default>1</show_in_default>
31
  <show_in_website>1</show_in_website>
32
  <show_in_store>1</show_in_store>
33
- </offer_category>
34
- <offer_mail translate="label">
35
- <label>Mail Notification.</label>
36
- <comment><![CDATA[This option will send a mail to the store email id with the products removed from
37
- Offer/Sale category.The product is only removed from the above category after the special price date ends]]></comment>
38
  <frontend_type>select</frontend_type>
39
- <source_model>adminhtml/system_config_source_yesno</source_model>
40
- <sort_order>10</sort_order>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
  <show_in_default>1</show_in_default>
42
  <show_in_website>1</show_in_website>
43
  <show_in_store>1</show_in_store>
44
- </offer_mail>
45
- <offer_cron translate="label">
46
- <label>Cron job after every Import.</label>
47
- <comment><![CDATA[A cron job will run immediately after every product import.All product will be checked for special price
48
- and will add to sale/offer category.]]></comment>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
  <frontend_type>select</frontend_type>
50
  <source_model>adminhtml/system_config_source_yesno</source_model>
51
  <sort_order>10</sort_order>
52
  <show_in_default>1</show_in_default>
53
  <show_in_website>1</show_in_website>
54
  <show_in_store>1</show_in_store>
55
- </offer_cron>
56
  </fields>
57
  </general>
58
 
18
  <show_in_default>1</show_in_default>
19
  <show_in_website>1</show_in_website>
20
  <show_in_store>1</show_in_store>
21
+ <fields>
22
+ <t_shirt_of_day_enable translate="label">
23
+ <label>T-Shirt Of Day Category Enable</label>
24
+ <comment><![CDATA[]]></comment>
 
 
25
  <frontend_type>select</frontend_type>
26
+ <source_model>adminhtml/system_config_source_yesno</source_model>
27
  <sort_order>3</sort_order>
28
  <show_in_default>1</show_in_default>
29
  <show_in_website>1</show_in_website>
30
  <show_in_store>1</show_in_store>
31
+ </t_shirt_of_day_enable>
32
+ <t_shirt_of_day translate="label">
33
+ <label>T-Shirt Of Day Category</label>
34
+ <comment><![CDATA[Automatically add/remove products into selected category according to the date specified in the "special_price" dates]]></comment>
 
35
  <frontend_type>select</frontend_type>
36
+ <source_model>Saleproducts/category</source_model>
37
+ <sort_order>4</sort_order>
38
+ <show_in_default>1</show_in_default>
39
+ <show_in_website>1</show_in_website>
40
+ <show_in_store>1</show_in_store>
41
+ <depends><t_shirt_of_day_enable>1</t_shirt_of_day_enable></depends>
42
+ </t_shirt_of_day>
43
+ <after_hour_enable translate="label">
44
+ <label>After Hour Category Enable</label>
45
+ <comment><![CDATA[]]></comment>
46
+ <frontend_type>select</frontend_type>
47
+ <source_model>adminhtml/system_config_source_yesno</source_model>
48
+ <sort_order>5</sort_order>
49
+ <show_in_default>1</show_in_default>
50
+ <show_in_website>1</show_in_website>
51
+ <show_in_store>1</show_in_store>
52
+ </after_hour_enable>
53
+ <after_hour translate="label">
54
+ <label>After Hour Category</label>
55
+ <comment><![CDATA[Automatically add/remove products into selected category according to the date specified in new attributes: "afterhours_from_date" and "afterhours_to_date"]]></comment>
56
+ <frontend_type>select</frontend_type>
57
+ <source_model>Saleproducts/category</source_model>
58
+ <sort_order>6</sort_order>
59
  <show_in_default>1</show_in_default>
60
  <show_in_website>1</show_in_website>
61
  <show_in_store>1</show_in_store>
62
+ <depends><after_hour_enable>1</after_hour_enable></depends>
63
+ </after_hour>
64
+ <gallery_enable translate="label">
65
+ <label>Gallery Category Enable</label>
66
+ <comment><![CDATA[]]></comment>
67
+ <frontend_type>select</frontend_type>
68
+ <source_model>adminhtml/system_config_source_yesno</source_model>
69
+ <sort_order>7</sort_order>
70
+ <show_in_default>1</show_in_default>
71
+ <show_in_website>1</show_in_website>
72
+ <show_in_store>1</show_in_store>
73
+ </gallery_enable>
74
+ <gallery translate="label">
75
+ <label>Gallery Category</label>
76
+ <comment><![CDATA[Automatically add/remove products into selected category according to the date specified in new attributes: "gallery_from_date" and "gallery_to_date"]]></comment>
77
+ <frontend_type>select</frontend_type>
78
+ <source_model>Saleproducts/category</source_model>
79
+ <sort_order>8</sort_order>
80
+ <show_in_default>1</show_in_default>
81
+ <show_in_website>1</show_in_website>
82
+ <show_in_store>1</show_in_store>
83
+ <depends><gallery_enable>1</gallery_enable></depends>
84
+ </gallery>
85
+ <offer_mail translate="label">
86
+ <label>Mail Notification.</label>
87
+ <comment><![CDATA[This option will send a mail to the store email id with the products Added/removed from
88
+ category.]]></comment>
89
  <frontend_type>select</frontend_type>
90
  <source_model>adminhtml/system_config_source_yesno</source_model>
91
  <sort_order>10</sort_order>
92
  <show_in_default>1</show_in_default>
93
  <show_in_website>1</show_in_website>
94
  <show_in_store>1</show_in_store>
95
+ </offer_mail>
96
  </fields>
97
  </general>
98
 
package.xml CHANGED
@@ -1,31 +1,34 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Automatic_Sale_Category</name>
4
- <version>1.0.0</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL)</license>
7
  <channel>community</channel>
8
  <extends/>
9
- <summary>Simple extension, automatically add products with special price to Sale or Offer category.</summary>
10
- <description>This extension will automatically add/remove products with special price into a Sale or Offer category according to the date specified. Daily Cron job to add or remove products from sale category. This extension also supports product import. If special price added in import csv, the product will automatically add to sale category.Administrator can create new category or existing category as sale category. &#xD;
11
  &#xD;
 
12
  &#xD;
 
13
  &#xD;
14
- </description>
15
  <notes>This extension will automatically add/remove products with special price into a Sale or Offer category according to the date specified.&#xD;
16
  &#xD;
 
 
 
17
  Supports:&#xD;
18
  MultiStore&#xD;
19
- Product import.&#xD;
20
- &#xD;
21
  Features:&#xD;
22
  Mail Notification&#xD;
23
- Cron Job&#xD;
24
- </notes>
25
- <authors><author><name>Manu Jose K</name><user>iammanujose</user><email>iammanujose@gmail.com</email></author></authors>
26
- <date>2012-07-31</date>
27
- <time>14:53:46</time>
28
- <contents><target name="magecommunity"><dir name="Manu"><dir><dir name="Saleproducts"><dir name="Block"><file name="Saleproducts.php" hash="09c109bb3f6ef9427b2364ffe544f5a8"/></dir><dir name="Helper"><file name="Data.php" hash="c18f385a84745660c1bc48c55961c101"/></dir><dir name="Model"><file name="Category.php" hash="9aff440bb5927d5e54584afa2bfa8519"/><file name="Observer.php" hash="ee71dd0379be18613ca3733dec3dd1d4"/></dir><dir name="controllers"><dir name="Catalog"><file name="ProductController.php" hash="d5c9b645f150c1e35f02a386670eff30"/></dir></dir><dir name="etc"><file name="config.xml" hash="09503480d196ec36a83dff45bbdfa408"/><file name="system.xml" hash="a190157bb6c2350d3df37e66f3e6b9df"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Manu_Saleproducts.xml" hash="10e0c0c0f2eb317ec09b8ba1889e04ce"/></dir></target></contents>
29
  <compatible/>
30
  <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
31
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Automatic_Sale_Category</name>
4
+ <version>1.2.0</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL)</license>
7
  <channel>community</channel>
8
  <extends/>
9
+ <summary>Simple extension, automatically add products with special price to selected category.</summary>
10
+ <description>This extension will automatically add/remove products with special price into a selected according to the date specified. Daily Cron job to add or remove products from sale category. If special price added in import csv, the product will automatically add to sale category.Administrator can create new category or existing category as sale category.&#xD;
11
  &#xD;
12
+ Automatically add/remove products into selected category according to the date specified in the "special_price" dates.&#xD;
13
  &#xD;
14
+ Automatically add/remove products into selected category according to the date specified in new attributes: "afterhours_from_date" and "afterhours_to_date"&#xD;
15
  &#xD;
16
+ Automatically add/remove products into selected category according to the date specified in new attributes: "gallery_from_date" and "gallery_to_date"</description>
17
  <notes>This extension will automatically add/remove products with special price into a Sale or Offer category according to the date specified.&#xD;
18
  &#xD;
19
+ Added functionality to support more attributes and categories.&#xD;
20
+ &#xD;
21
+ Fixed bug in date comparison.&#xD;
22
  Supports:&#xD;
23
  MultiStore&#xD;
24
+ Product import&#xD;
 
25
  Features:&#xD;
26
  Mail Notification&#xD;
27
+ Cron Job</notes>
28
+ <authors><author><name>Manu Jose</name><user>iammanujose</user><email>iammanujose@gmail.com</email></author></authors>
29
+ <date>2013-03-21</date>
30
+ <time>00:48:59</time>
31
+ <contents><target name="magecommunity"><dir name="Manu"><dir name="Saleproducts"><dir name="Block"><file name="Saleproducts.php" hash="09c109bb3f6ef9427b2364ffe544f5a8"/></dir><dir name="Helper"><file name="Data.php" hash="c18f385a84745660c1bc48c55961c101"/></dir><dir name="Model"><file name="Category.php" hash="d38cf841ec5a8e42ea25eda934f1389f"/><file name="Observer.php" hash="0a8ac8d447de74a0790ebfb3016c0e41"/></dir><dir name="controllers"><dir name="Catalog"><file name="ProductController.php" hash="cda0a40941a1f14f811e9d9d430aed1c"/></dir></dir><dir name="etc"><file name="config.xml" hash="78c5bc1cbe1b08cc808bfdda77edff4e"/><file name="system.xml" hash="22cb1bdbf2f3ee2743cf6e72205030ea"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Manu_Saleproducts.xml" hash="10e0c0c0f2eb317ec09b8ba1889e04ce"/></dir></target></contents>
 
32
  <compatible/>
33
  <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
34
  </package>