Version Notes
[+] Content search support added.
[!] Invalid data could be submitted on category change. Fixed.
Download this release
Release Info
Developer | Simbirsk Technologies, Ltd. |
Extension | Simtech_Searchanise |
Version | 3.0.2 |
Comparing to | |
See all releases |
Code changes from version 3.0.1 to 3.0.2
- app/code/community/Simtech/Searchanise/Helper/ApiCategories.php +3 -3
- app/code/community/Simtech/Searchanise/Helper/ApiPages.php +216 -0
- app/code/community/Simtech/Searchanise/Helper/ApiProducts.php +113 -21
- app/code/community/Simtech/Searchanise/Helper/ApiSe.php +20 -98
- app/code/community/Simtech/Searchanise/Model/Observer.php +57 -0
- app/code/community/Simtech/Searchanise/Model/Queue.php +56 -21
- app/code/community/Simtech/Searchanise/controllers/InfoController.php +7 -1
- app/code/community/Simtech/Searchanise/etc/config.xml +28 -2
- app/code/community/Simtech/Searchanise/etc/config_without_search.xml +28 -2
- package.xml +6 -5
app/code/community/Simtech/Searchanise/Helper/ApiCategories.php
CHANGED
@@ -127,7 +127,7 @@ class Simtech_Searchanise_Helper_ApiCategories extends Mage_Core_Helper_Data
|
|
127 |
->addAttributeToSort('entity_id', Varien_Data_Collection::SORT_ORDER_ASC)
|
128 |
->setPageSize(1);
|
129 |
if ($store) {
|
130 |
-
$categoryStartCollection = $categoryStartCollection->setStoreId($store->getId())
|
131 |
}
|
132 |
$categoryStartCollection = $categoryStartCollection->load();
|
133 |
|
@@ -136,7 +136,7 @@ class Simtech_Searchanise_Helper_ApiCategories extends Mage_Core_Helper_Data
|
|
136 |
->addAttributeToSort('entity_id', Varien_Data_Collection::SORT_ORDER_DESC)
|
137 |
->setPageSize(1);
|
138 |
if ($store) {
|
139 |
-
$categoryEndCollection = $categoryEndCollection->setStoreId($store->getId())
|
140 |
}
|
141 |
|
142 |
$categoryEndCollection = $categoryEndCollection->load();
|
@@ -170,7 +170,7 @@ class Simtech_Searchanise_Helper_ApiCategories extends Mage_Core_Helper_Data
|
|
170 |
->setPageSize($step);
|
171 |
|
172 |
if ($store) {
|
173 |
-
$categories = $categories->setStoreId($store->getId())
|
174 |
}
|
175 |
|
176 |
$categories = $categories->load();
|
127 |
->addAttributeToSort('entity_id', Varien_Data_Collection::SORT_ORDER_ASC)
|
128 |
->setPageSize(1);
|
129 |
if ($store) {
|
130 |
+
$categoryStartCollection = $categoryStartCollection->setStoreId($store->getId());
|
131 |
}
|
132 |
$categoryStartCollection = $categoryStartCollection->load();
|
133 |
|
136 |
->addAttributeToSort('entity_id', Varien_Data_Collection::SORT_ORDER_DESC)
|
137 |
->setPageSize(1);
|
138 |
if ($store) {
|
139 |
+
$categoryEndCollection = $categoryEndCollection->setStoreId($store->getId());
|
140 |
}
|
141 |
|
142 |
$categoryEndCollection = $categoryEndCollection->load();
|
170 |
->setPageSize($step);
|
171 |
|
172 |
if ($store) {
|
173 |
+
$categories = $categories->setStoreId($store->getId());
|
174 |
}
|
175 |
|
176 |
$categories = $categories->load();
|
app/code/community/Simtech/Searchanise/Helper/ApiPages.php
ADDED
@@ -0,0 +1,216 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/***************************************************************************
|
3 |
+
* *
|
4 |
+
* (c) 2004 Vladimir V. Kalynyak, Alexey V. Vinokurov, Ilya M. Shalnev *
|
5 |
+
* *
|
6 |
+
* This is commercial software, only users who have purchased a valid *
|
7 |
+
* license and accept to the terms of the License Agreement can install *
|
8 |
+
* and use this program. *
|
9 |
+
* *
|
10 |
+
****************************************************************************
|
11 |
+
* PLEASE READ THE FULL TEXT OF THE SOFTWARE LICENSE AGREEMENT IN THE *
|
12 |
+
* "copyright.txt" FILE PROVIDED WITH THIS DISTRIBUTION PACKAGE. *
|
13 |
+
****************************************************************************/
|
14 |
+
|
15 |
+
class Simtech_Searchanise_Helper_ApiPages extends Mage_Core_Helper_Data
|
16 |
+
{
|
17 |
+
private static $_excludedPages = array(
|
18 |
+
'no-route', // 404 page
|
19 |
+
);
|
20 |
+
|
21 |
+
public static function generatePageFeed($page, $store = null, $checkData = true)
|
22 |
+
{
|
23 |
+
$item = array();
|
24 |
+
|
25 |
+
if ($checkData) {
|
26 |
+
if (!$page ||
|
27 |
+
!$page->getId() ||
|
28 |
+
!$page->getTitle() ||
|
29 |
+
!$page->getIsActive() ||
|
30 |
+
in_array($page->getIdentifier(), self::$_excludedPages)
|
31 |
+
) {
|
32 |
+
return $item;
|
33 |
+
}
|
34 |
+
}
|
35 |
+
// Need for generate correct url.
|
36 |
+
if ($store) {
|
37 |
+
Mage::app()->setCurrentStore($store->getId());
|
38 |
+
} else {
|
39 |
+
Mage::app()->setCurrentStore(0);
|
40 |
+
}
|
41 |
+
|
42 |
+
$item['id'] = $page->getId();
|
43 |
+
$item['title'] = $page->getTitle();
|
44 |
+
$item['link'] = Mage::helper('cms/page')->getPageUrl($page->getId());
|
45 |
+
$item['summary'] = $page->getContent();
|
46 |
+
|
47 |
+
return $item;
|
48 |
+
}
|
49 |
+
|
50 |
+
public static function getPages($pageIds = Simtech_Searchanise_Model_Queue::NOT_DATA, $store = null)
|
51 |
+
{
|
52 |
+
static $arrPages = array();
|
53 |
+
|
54 |
+
$keyPages = '';
|
55 |
+
if ($pageIds) {
|
56 |
+
if (is_array($pageIds)) {
|
57 |
+
$keyPages .= implode('_', $pageIds);
|
58 |
+
} else {
|
59 |
+
$keyPages .= $pageIds;
|
60 |
+
}
|
61 |
+
}
|
62 |
+
$storeId = $store ? $store->getId() : 0;
|
63 |
+
$keyPages .= ':' . $storeId;
|
64 |
+
|
65 |
+
if (isset($arrPages[$keyPages])) {
|
66 |
+
// Nothing
|
67 |
+
} else {
|
68 |
+
$collection = Mage::getModel('cms/page')->getCollection();
|
69 |
+
|
70 |
+
/* @var $collection Mage_Catalog_Model_Resource_Eav_Mysql4_Page_Collection */
|
71 |
+
$collection->addStoreFilter($storeId);
|
72 |
+
|
73 |
+
if ($pageIds !== Simtech_Searchanise_Model_Queue::NOT_DATA) {
|
74 |
+
// Already exist automatic definition 'one value' or 'array'.
|
75 |
+
self::_addIdFilter($collection, $pageIds);
|
76 |
+
}
|
77 |
+
|
78 |
+
$collection->load();
|
79 |
+
|
80 |
+
$arrPages[$keyPages] = $collection;
|
81 |
+
}
|
82 |
+
|
83 |
+
return $arrPages[$keyPages];
|
84 |
+
}
|
85 |
+
|
86 |
+
public static function generatePagesFeed($pageIds = Simtech_Searchanise_Model_Queue::NOT_DATA, $store = null, $checkData = true)
|
87 |
+
{
|
88 |
+
$items = array();
|
89 |
+
|
90 |
+
$pages = self::getPages($pageIds, $store);
|
91 |
+
|
92 |
+
if ($pages) {
|
93 |
+
foreach ($pages as $page) {
|
94 |
+
if ($item = self::generatePageFeed($page, $store, $checkData)) {
|
95 |
+
$items[] = $item;
|
96 |
+
}
|
97 |
+
}
|
98 |
+
}
|
99 |
+
|
100 |
+
return $items;
|
101 |
+
}
|
102 |
+
|
103 |
+
public static function getMinMaxPageId($store = null)
|
104 |
+
{
|
105 |
+
$startId = 0;
|
106 |
+
$endId = 0;
|
107 |
+
|
108 |
+
$pageStartCollection = Mage::getModel('cms/page')
|
109 |
+
->getCollection()
|
110 |
+
->setPageSize(1);
|
111 |
+
self::_addAttributeToSort($pageStartCollection, 'page_id', Varien_Data_Collection::SORT_ORDER_ASC);
|
112 |
+
if ($store) {
|
113 |
+
$pageStartCollection = $pageStartCollection->addStoreFilter($store->getId());
|
114 |
+
}
|
115 |
+
$pageStartCollection = $pageStartCollection->load();
|
116 |
+
|
117 |
+
$pageEndCollection = Mage::getModel('cms/page')
|
118 |
+
->getCollection()
|
119 |
+
->setPageSize(1);
|
120 |
+
self::_addAttributeToSort($pageEndCollection, 'page_id', Varien_Data_Collection::SORT_ORDER_DESC);
|
121 |
+
if ($store) {
|
122 |
+
$pageEndCollection = $pageEndCollection->addStoreFilter($store->getId());
|
123 |
+
}
|
124 |
+
|
125 |
+
$pageEndCollection = $pageEndCollection->load();
|
126 |
+
|
127 |
+
if ($pageStartCollection) {
|
128 |
+
$pageArr = $pageStartCollection->toArray(array('page_id'));
|
129 |
+
if (!empty($pageArr)) {
|
130 |
+
$firstItem = reset($pageArr);
|
131 |
+
$startId = $firstItem['page_id'];
|
132 |
+
}
|
133 |
+
}
|
134 |
+
|
135 |
+
if ($pageEndCollection) {
|
136 |
+
$pageArr = $pageEndCollection->toArray(array('page_id'));
|
137 |
+
if (!empty($pageArr)) {
|
138 |
+
$firstItem = reset($pageArr);
|
139 |
+
$endId = $firstItem['page_id'];
|
140 |
+
}
|
141 |
+
}
|
142 |
+
|
143 |
+
return array($startId, $endId);
|
144 |
+
}
|
145 |
+
|
146 |
+
public static function getPageIdsFormRange($start, $end, $step, $store = null)
|
147 |
+
{
|
148 |
+
$arrPages = array();
|
149 |
+
|
150 |
+
$pages = Mage::getModel('cms/page')
|
151 |
+
->getCollection()
|
152 |
+
->addFieldToFilter('page_id', array("from" => $start, "to" => $end))
|
153 |
+
->setPageSize($step);
|
154 |
+
|
155 |
+
if ($store) {
|
156 |
+
$pages = $pages->addStoreFilter($store->getId());
|
157 |
+
}
|
158 |
+
|
159 |
+
$pages = $pages->load();
|
160 |
+
if ($pages) {
|
161 |
+
// Not used because 'arrPages' comprising 'stock_item' field and is 'array(array())'
|
162 |
+
// $arrPages = $pages->toArray(array('page_id'));
|
163 |
+
foreach ($pages as $page) {
|
164 |
+
$arrPages[] = $page->getId();
|
165 |
+
}
|
166 |
+
}
|
167 |
+
// It is necessary for save memory.
|
168 |
+
unset($pages);
|
169 |
+
|
170 |
+
return $arrPages;
|
171 |
+
}
|
172 |
+
|
173 |
+
/**
|
174 |
+
* Add Id filter
|
175 |
+
*
|
176 |
+
* @param array $pageIds
|
177 |
+
* @return Mage_Catalog_Model_Resource_Page_Collection
|
178 |
+
*/
|
179 |
+
private static function _addIdFilter(&$collection, $pageIds)
|
180 |
+
{
|
181 |
+
if (is_array($pageIds)) {
|
182 |
+
if (empty($pageIds)) {
|
183 |
+
$condition = '';
|
184 |
+
} else {
|
185 |
+
$condition = array('in' => $pageIds);
|
186 |
+
}
|
187 |
+
} elseif (is_numeric($pageIds)) {
|
188 |
+
$condition = $pageIds;
|
189 |
+
} elseif (is_string($pageIds)) {
|
190 |
+
$ids = explode(',', $pageIds);
|
191 |
+
if (empty($ids)) {
|
192 |
+
$condition = $pageIds;
|
193 |
+
} else {
|
194 |
+
$condition = array('in' => $ids);
|
195 |
+
}
|
196 |
+
}
|
197 |
+
|
198 |
+
return $collection->addFieldToFilter('page_id', $condition);
|
199 |
+
}
|
200 |
+
|
201 |
+
/**
|
202 |
+
* Add attribute to sort order
|
203 |
+
*
|
204 |
+
* @param string $attribute
|
205 |
+
* @param string $dir
|
206 |
+
* @return Mage_Catalog_Model_Resource_Pages_Flat_Collection
|
207 |
+
*/
|
208 |
+
private static function _addAttributeToSort(&$collection, $attribute, $dir = Varien_Data_Collection::SORT_ORDER_ASC)
|
209 |
+
{
|
210 |
+
if (!is_string($attribute)) {
|
211 |
+
return $collection;
|
212 |
+
}
|
213 |
+
|
214 |
+
return $collection->setOrder($attribute, $dir);;
|
215 |
+
}
|
216 |
+
}
|
app/code/community/Simtech/Searchanise/Helper/ApiProducts.php
CHANGED
@@ -939,31 +939,36 @@ class Simtech_Searchanise_Helper_ApiProducts extends Mage_Core_Helper_Data
|
|
939 |
if (isset($arrProducts[$keyProducts])) {
|
940 |
// Nothing
|
941 |
} else {
|
942 |
-
$products =
|
943 |
-
|
944 |
-
|
945 |
-
|
946 |
-
|
947 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
948 |
if ($store) {
|
949 |
-
$products
|
950 |
-
|
951 |
-
|
952 |
}
|
953 |
-
}
|
954 |
|
955 |
-
|
956 |
-
|
957 |
-
->
|
958 |
-
|
959 |
-
}
|
960 |
-
|
961 |
-
if ($productIds !== Simtech_Searchanise_Model_Queue::NOT_DATA) {
|
962 |
-
// Already exist automatic definition 'one value' or 'array'.
|
963 |
-
$products->addIdFilter($productIds);
|
964 |
-
}
|
965 |
|
966 |
-
|
|
|
967 |
|
968 |
// Fixme in the future
|
969 |
// Maybe create cache without customerGroupId and setCustomerGroupId after using cache.
|
@@ -1005,6 +1010,93 @@ class Simtech_Searchanise_Helper_ApiProducts extends Mage_Core_Helper_Data
|
|
1005 |
return $items;
|
1006 |
}
|
1007 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1008 |
private static function _getRequiredAttributes()
|
1009 |
{
|
1010 |
static $requiredAttributes;
|
939 |
if (isset($arrProducts[$keyProducts])) {
|
940 |
// Nothing
|
941 |
} else {
|
942 |
+
$products = array();
|
943 |
+
if (self::$isGetProductsByItems) {
|
944 |
+
$products = self::_getProductsByItems($productIds, $store);
|
945 |
+
} else {
|
946 |
+
$products = Mage::getModel('catalog/product')
|
947 |
+
->getCollection()
|
948 |
+
->addAttributeToSelect('*')
|
949 |
+
->addUrlRewrite();
|
950 |
+
|
951 |
+
if ($customerGroupId != null) {
|
952 |
+
if ($store) {
|
953 |
+
$products->addPriceData($customerGroupId, $store->getWebsiteId());
|
954 |
+
} else {
|
955 |
+
$products->addPriceData($customerGroupId);
|
956 |
+
}
|
957 |
+
}
|
958 |
+
|
959 |
if ($store) {
|
960 |
+
$products
|
961 |
+
->setStoreId($store)
|
962 |
+
->addStoreFilter($store);
|
963 |
}
|
|
|
964 |
|
965 |
+
if ($productIds !== Simtech_Searchanise_Model_Queue::NOT_DATA) {
|
966 |
+
// Already exist automatic definition 'one value' or 'array'.
|
967 |
+
$products->addIdFilter($productIds);
|
968 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
969 |
|
970 |
+
$products->load();
|
971 |
+
}
|
972 |
|
973 |
// Fixme in the future
|
974 |
// Maybe create cache without customerGroupId and setCustomerGroupId after using cache.
|
1010 |
return $items;
|
1011 |
}
|
1012 |
|
1013 |
+
public static function getMinMaxProductId($store = null)
|
1014 |
+
{
|
1015 |
+
$startId = 0;
|
1016 |
+
$endId = 0;
|
1017 |
+
|
1018 |
+
$productStartCollection = Mage::getModel('catalog/product')
|
1019 |
+
->getCollection()
|
1020 |
+
->addAttributeToSort('entity_id', Varien_Data_Collection::SORT_ORDER_ASC)
|
1021 |
+
->setPageSize(1);
|
1022 |
+
if ($store) {
|
1023 |
+
$productStartCollection = $productStartCollection->addStoreFilter($store);
|
1024 |
+
}
|
1025 |
+
$productStartCollection = $productStartCollection->load();
|
1026 |
+
|
1027 |
+
$productEndCollection = Mage::getModel('catalog/product')
|
1028 |
+
->getCollection()
|
1029 |
+
->addAttributeToSort('entity_id', Varien_Data_Collection::SORT_ORDER_DESC)
|
1030 |
+
->setPageSize(1);
|
1031 |
+
if ($store) {
|
1032 |
+
$productEndCollection = $productEndCollection->addStoreFilter($store);
|
1033 |
+
}
|
1034 |
+
$productEndCollection = $productEndCollection->load();
|
1035 |
+
|
1036 |
+
if ($productStartCollection) {
|
1037 |
+
$productArr = $productStartCollection->toArray(array('entity_id'));
|
1038 |
+
if (!empty($productArr)) {
|
1039 |
+
$firstItem = reset($productArr);
|
1040 |
+
$startId = $firstItem['entity_id'];
|
1041 |
+
}
|
1042 |
+
}
|
1043 |
+
|
1044 |
+
if ($productEndCollection) {
|
1045 |
+
$productArr = $productEndCollection->toArray(array('entity_id'));
|
1046 |
+
if (!empty($productArr)) {
|
1047 |
+
$firstItem = reset($productArr);
|
1048 |
+
$endId = $firstItem['entity_id'];
|
1049 |
+
}
|
1050 |
+
}
|
1051 |
+
|
1052 |
+
return array($startId, $endId);
|
1053 |
+
}
|
1054 |
+
|
1055 |
+
public static function getProductIdsFormRange($start, $end, $step, $store = null, $isOnlyActive = false)
|
1056 |
+
{
|
1057 |
+
$arrProducts = array();
|
1058 |
+
// Need for get correct products.
|
1059 |
+
if ($store) {
|
1060 |
+
Mage::app()->setCurrentStore($store->getId());
|
1061 |
+
} else {
|
1062 |
+
Mage::app()->setCurrentStore(0);
|
1063 |
+
}
|
1064 |
+
|
1065 |
+
$products = Mage::getModel('catalog/product')
|
1066 |
+
->getCollection()
|
1067 |
+
->addFieldToFilter('entity_id', array("from" => $start, "to" => $end))
|
1068 |
+
->setPageSize($step);
|
1069 |
+
|
1070 |
+
if ($store) {
|
1071 |
+
$products->addStoreFilter($store);
|
1072 |
+
}
|
1073 |
+
|
1074 |
+
if ($isOnlyActive) {
|
1075 |
+
Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($products);
|
1076 |
+
// Fixme in the future
|
1077 |
+
// It may require to disable "product visibility" filter if "is full feed".
|
1078 |
+
if (Mage::helper('searchanise/ApiSe')->getUseFullFeed() || Mage::helper('searchanise/ApiSe')->getUseNavigation()) {
|
1079 |
+
Mage::getSingleton('catalog/product_visibility')->addVisibleInSiteFilterToCollection($products);
|
1080 |
+
} else {
|
1081 |
+
Mage::getSingleton('catalog/product_visibility')->addVisibleInSearchFilterToCollection($products);
|
1082 |
+
}
|
1083 |
+
// end fixme
|
1084 |
+
}
|
1085 |
+
|
1086 |
+
$products->load();
|
1087 |
+
if ($products) {
|
1088 |
+
// Not used because 'arrProducts' comprising 'stock_item' field and is 'array(array())'
|
1089 |
+
// $arrProducts = $products->toArray(array('entity_id'));
|
1090 |
+
foreach ($products as $product) {
|
1091 |
+
$arrProducts[] = $product->getId();
|
1092 |
+
}
|
1093 |
+
}
|
1094 |
+
// It is necessary for save memory.
|
1095 |
+
unset($products);
|
1096 |
+
|
1097 |
+
return $arrProducts;
|
1098 |
+
}
|
1099 |
+
|
1100 |
private static function _getRequiredAttributes()
|
1101 |
{
|
1102 |
static $requiredAttributes;
|
app/code/community/Simtech/Searchanise/Helper/ApiSe.php
CHANGED
@@ -545,6 +545,11 @@ class Simtech_Searchanise_Helper_ApiSe
|
|
545 |
{
|
546 |
return self::getSetting('categories_per_pass');
|
547 |
}
|
|
|
|
|
|
|
|
|
|
|
548 |
|
549 |
public static function getMaxErrorCount()
|
550 |
{
|
@@ -1150,94 +1155,7 @@ class Simtech_Searchanise_Helper_ApiSe
|
|
1150 |
|
1151 |
return $connected;
|
1152 |
}
|
1153 |
-
|
1154 |
-
public static function getMinMaxProductId($store = null)
|
1155 |
-
{
|
1156 |
-
$startId = 0;
|
1157 |
-
$endId = 0;
|
1158 |
-
|
1159 |
-
$productStartCollection = Mage::getModel('catalog/product')
|
1160 |
-
->getCollection()
|
1161 |
-
->addAttributeToSort('entity_id', Varien_Data_Collection::SORT_ORDER_ASC)
|
1162 |
-
->setPageSize(1);
|
1163 |
-
if ($store) {
|
1164 |
-
$productStartCollection = $productStartCollection->addStoreFilter($store);
|
1165 |
-
}
|
1166 |
-
$productStartCollection = $productStartCollection->load();
|
1167 |
-
|
1168 |
-
$productEndCollection = Mage::getModel('catalog/product')
|
1169 |
-
->getCollection()
|
1170 |
-
->addAttributeToSort('entity_id', Varien_Data_Collection::SORT_ORDER_DESC)
|
1171 |
-
->setPageSize(1);
|
1172 |
-
if ($store) {
|
1173 |
-
$productEndCollection = $productEndCollection->addStoreFilter($store);
|
1174 |
-
}
|
1175 |
-
$productEndCollection = $productEndCollection->load();
|
1176 |
-
|
1177 |
-
if ($productStartCollection) {
|
1178 |
-
$productArr = $productStartCollection->toArray(array('entity_id'));
|
1179 |
-
if (!empty($productArr)) {
|
1180 |
-
$firstItem = reset($productArr);
|
1181 |
-
$startId = $firstItem['entity_id'];
|
1182 |
-
}
|
1183 |
-
}
|
1184 |
-
|
1185 |
-
if ($productEndCollection) {
|
1186 |
-
$productArr = $productEndCollection->toArray(array('entity_id'));
|
1187 |
-
if (!empty($productArr)) {
|
1188 |
-
$firstItem = reset($productArr);
|
1189 |
-
$endId = $firstItem['entity_id'];
|
1190 |
-
}
|
1191 |
-
}
|
1192 |
-
|
1193 |
-
return array($startId, $endId);
|
1194 |
-
}
|
1195 |
-
|
1196 |
-
public static function getProductIdsFormRange($start, $end, $step, $store = null, $isOnlyActive = false)
|
1197 |
-
{
|
1198 |
-
$arrProducts = array();
|
1199 |
-
// Need for get correct products.
|
1200 |
-
if ($store) {
|
1201 |
-
Mage::app()->setCurrentStore($store->getId());
|
1202 |
-
} else {
|
1203 |
-
Mage::app()->setCurrentStore(0);
|
1204 |
-
}
|
1205 |
-
|
1206 |
-
$products = Mage::getModel('catalog/product')
|
1207 |
-
->getCollection()
|
1208 |
-
->addFieldToFilter('entity_id', array("from" => $start, "to" => $end))
|
1209 |
-
->setPageSize($step);
|
1210 |
-
|
1211 |
-
if ($store) {
|
1212 |
-
$products->addStoreFilter($store);
|
1213 |
-
}
|
1214 |
-
|
1215 |
-
if ($isOnlyActive) {
|
1216 |
-
Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($products);
|
1217 |
-
// Fixme in the future
|
1218 |
-
// It may require to disable "product visibility" filter if "is full feed".
|
1219 |
-
if (self::getUseFullFeed() || self::getUseNavigation()) {
|
1220 |
-
Mage::getSingleton('catalog/product_visibility')->addVisibleInSiteFilterToCollection($products);
|
1221 |
-
} else {
|
1222 |
-
Mage::getSingleton('catalog/product_visibility')->addVisibleInSearchFilterToCollection($products);
|
1223 |
-
}
|
1224 |
-
// end fixme
|
1225 |
-
}
|
1226 |
-
|
1227 |
-
$products->load();
|
1228 |
-
if ($products) {
|
1229 |
-
// Not used because 'arrProducts' comprising 'stock_item' field and is 'array(array())'
|
1230 |
-
// $arrProducts = $products->toArray(array('entity_id'));
|
1231 |
-
foreach ($products as $product) {
|
1232 |
-
$arrProducts[] = $product->getId();
|
1233 |
-
}
|
1234 |
-
}
|
1235 |
-
// It is necessary for save memory.
|
1236 |
-
unset($products);
|
1237 |
|
1238 |
-
return $arrProducts;
|
1239 |
-
}
|
1240 |
-
|
1241 |
public static function getFilterableFiltersIds($store = null)
|
1242 |
{
|
1243 |
$arrFilters = array();
|
@@ -1364,10 +1282,13 @@ class Simtech_Searchanise_Helper_ApiSe
|
|
1364 |
|
1365 |
if ($action == Simtech_Searchanise_Model_Queue::ACT_UPDATE_PRODUCTS) {
|
1366 |
$step = self::getProductsPerPass() * 50;
|
1367 |
-
list($start, $max) =
|
1368 |
} elseif ($action == Simtech_Searchanise_Model_Queue::ACT_UPDATE_CATEGORIES) {
|
1369 |
$step = self::getCategoriesPerPass() * 50;
|
1370 |
list($start, $max) = Mage::helper('searchanise/ApiCategories')->getMinMaxCategoryId($store);
|
|
|
|
|
|
|
1371 |
}
|
1372 |
|
1373 |
do {
|
@@ -1375,9 +1296,11 @@ class Simtech_Searchanise_Helper_ApiSe
|
|
1375 |
$chunkItemIds = null;
|
1376 |
|
1377 |
if ($action == Simtech_Searchanise_Model_Queue::ACT_UPDATE_PRODUCTS) {
|
1378 |
-
$chunkItemIds =
|
1379 |
} elseif ($action == Simtech_Searchanise_Model_Queue::ACT_UPDATE_CATEGORIES) {
|
1380 |
$chunkItemIds = Mage::helper('searchanise/ApiCategories')->getCategoryIdsFormRange($start, $end, $step, $store);
|
|
|
|
|
1381 |
}
|
1382 |
|
1383 |
$start = $end + 1;
|
@@ -1501,6 +1424,7 @@ class Simtech_Searchanise_Helper_ApiSe
|
|
1501 |
|
1502 |
self::_addTaskByChunk($store, $action = Simtech_Searchanise_Model_Queue::ACT_UPDATE_PRODUCTS, true);
|
1503 |
self::_addTaskByChunk($store, $action = Simtech_Searchanise_Model_Queue::ACT_UPDATE_CATEGORIES, true);
|
|
|
1504 |
|
1505 |
self::echoConnectProgress('.');
|
1506 |
|
@@ -1556,15 +1480,13 @@ class Simtech_Searchanise_Helper_ApiSe
|
|
1556 |
}
|
1557 |
|
1558 |
} elseif ($q['action'] == Simtech_Searchanise_Model_Queue::ACT_UPDATE_PAGES) {
|
1559 |
-
|
1560 |
-
|
1561 |
-
|
1562 |
-
|
1563 |
-
|
1564 |
-
|
1565 |
-
|
1566 |
-
// }
|
1567 |
-
// end fixme
|
1568 |
} elseif ($q['action'] == Simtech_Searchanise_Model_Queue::ACT_UPDATE_ATTRIBUTES) {
|
1569 |
$schema = null;
|
1570 |
|
545 |
{
|
546 |
return self::getSetting('categories_per_pass');
|
547 |
}
|
548 |
+
|
549 |
+
public static function getPagesPerPass()
|
550 |
+
{
|
551 |
+
return self::getSetting('pages_per_pass');
|
552 |
+
}
|
553 |
|
554 |
public static function getMaxErrorCount()
|
555 |
{
|
1155 |
|
1156 |
return $connected;
|
1157 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1158 |
|
|
|
|
|
|
|
1159 |
public static function getFilterableFiltersIds($store = null)
|
1160 |
{
|
1161 |
$arrFilters = array();
|
1282 |
|
1283 |
if ($action == Simtech_Searchanise_Model_Queue::ACT_UPDATE_PRODUCTS) {
|
1284 |
$step = self::getProductsPerPass() * 50;
|
1285 |
+
list($start, $max) = Mage::helper('searchanise/ApiProducts')->getMinMaxProductId($store);
|
1286 |
} elseif ($action == Simtech_Searchanise_Model_Queue::ACT_UPDATE_CATEGORIES) {
|
1287 |
$step = self::getCategoriesPerPass() * 50;
|
1288 |
list($start, $max) = Mage::helper('searchanise/ApiCategories')->getMinMaxCategoryId($store);
|
1289 |
+
} elseif ($action == Simtech_Searchanise_Model_Queue::ACT_UPDATE_PAGES) {
|
1290 |
+
$step = self::getPagesPerPass() * 50;
|
1291 |
+
list($start, $max) = Mage::helper('searchanise/ApiPages')->getMinMaxPageId($store);
|
1292 |
}
|
1293 |
|
1294 |
do {
|
1296 |
$chunkItemIds = null;
|
1297 |
|
1298 |
if ($action == Simtech_Searchanise_Model_Queue::ACT_UPDATE_PRODUCTS) {
|
1299 |
+
$chunkItemIds = Mage::helper('searchanise/ApiProducts')->getProductIdsFormRange($start, $end, $step, $store, $isOnlyActive);
|
1300 |
} elseif ($action == Simtech_Searchanise_Model_Queue::ACT_UPDATE_CATEGORIES) {
|
1301 |
$chunkItemIds = Mage::helper('searchanise/ApiCategories')->getCategoryIdsFormRange($start, $end, $step, $store);
|
1302 |
+
} elseif ($action == Simtech_Searchanise_Model_Queue::ACT_UPDATE_PAGES) {
|
1303 |
+
$chunkItemIds = Mage::helper('searchanise/ApiPages')->getPageIdsFormRange($start, $end, $step, $store);
|
1304 |
}
|
1305 |
|
1306 |
$start = $end + 1;
|
1424 |
|
1425 |
self::_addTaskByChunk($store, $action = Simtech_Searchanise_Model_Queue::ACT_UPDATE_PRODUCTS, true);
|
1426 |
self::_addTaskByChunk($store, $action = Simtech_Searchanise_Model_Queue::ACT_UPDATE_CATEGORIES, true);
|
1427 |
+
self::_addTaskByChunk($store, $action = Simtech_Searchanise_Model_Queue::ACT_UPDATE_PAGES, true);
|
1428 |
|
1429 |
self::echoConnectProgress('.');
|
1430 |
|
1480 |
}
|
1481 |
|
1482 |
} elseif ($q['action'] == Simtech_Searchanise_Model_Queue::ACT_UPDATE_PAGES) {
|
1483 |
+
$pages = Mage::helper('searchanise/ApiPages')->generatePagesFeed($data, $store);
|
1484 |
+
if (!empty($pages)) {
|
1485 |
+
$dataForSend = array(
|
1486 |
+
'header' => $header,
|
1487 |
+
'pages' => $pages,
|
1488 |
+
);
|
1489 |
+
}
|
|
|
|
|
1490 |
} elseif ($q['action'] == Simtech_Searchanise_Model_Queue::ACT_UPDATE_ATTRIBUTES) {
|
1491 |
$schema = null;
|
1492 |
|
app/code/community/Simtech/Searchanise/Model/Observer.php
CHANGED
@@ -16,6 +16,7 @@ class Simtech_Searchanise_Model_Observer
|
|
16 |
{
|
17 |
protected static $productIdsInCategory = array();
|
18 |
protected static $isExistsCategory = false;
|
|
|
19 |
|
20 |
public function __construct()
|
21 |
{
|
@@ -293,6 +294,62 @@ class Simtech_Searchanise_Model_Observer
|
|
293 |
return $this;
|
294 |
}
|
295 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
296 |
// FOR SALES //
|
297 |
/**
|
298 |
*
|
16 |
{
|
17 |
protected static $productIdsInCategory = array();
|
18 |
protected static $isExistsCategory = false;
|
19 |
+
protected static $isExistsPage = false;
|
20 |
|
21 |
public function __construct()
|
22 |
{
|
294 |
return $this;
|
295 |
}
|
296 |
|
297 |
+
// FOR PAGES //
|
298 |
+
/**
|
299 |
+
* Delete page before
|
300 |
+
*
|
301 |
+
* @param Varien_Event_Observer $observer
|
302 |
+
* @return Mage_CmsIndex_Model_Observer
|
303 |
+
*/
|
304 |
+
public function cmsPageDeleteBefore(Varien_Event_Observer $observer)
|
305 |
+
{
|
306 |
+
$page = $observer->getEvent()->getObject();
|
307 |
+
|
308 |
+
if ($page && $page->getId()) {
|
309 |
+
Mage::getModel('searchanise/queue')->addActionPage($page, Simtech_Searchanise_Model_Queue::ACT_DELETE_PAGES);
|
310 |
+
}
|
311 |
+
|
312 |
+
return $this;
|
313 |
+
}
|
314 |
+
|
315 |
+
/**
|
316 |
+
* Save page before
|
317 |
+
*
|
318 |
+
* @param Varien_Event_Observer $observer
|
319 |
+
* @return Mage_CmsIndex_Model_Observer
|
320 |
+
*/
|
321 |
+
public function cmsPageSaveBefore(Varien_Event_Observer $observer)
|
322 |
+
{
|
323 |
+
$page = $observer->getEvent()->getObject();
|
324 |
+
|
325 |
+
if ($page && $page->getId()) {
|
326 |
+
self::$isExistsPage = true; // New page doesn't run the cmsPageSaveBefore function.
|
327 |
+
Mage::getModel('searchanise/queue')->addActionPage($page);
|
328 |
+
}
|
329 |
+
|
330 |
+
return $this;
|
331 |
+
}
|
332 |
+
|
333 |
+
/**
|
334 |
+
* Save page after
|
335 |
+
*
|
336 |
+
* @param Varien_Event_Observer $observer
|
337 |
+
* @return Mage_CmsIndex_Model_Observer
|
338 |
+
*/
|
339 |
+
public function cmsPageSaveAfter(Varien_Event_Observer $observer)
|
340 |
+
{
|
341 |
+
$page = $observer->getEvent()->getObject();
|
342 |
+
|
343 |
+
if ($page && $page->getId()) {
|
344 |
+
if (!self::$isExistsPage) { // if page was created now
|
345 |
+
Mage::getModel('searchanise/queue')->addActionPage($page);
|
346 |
+
}
|
347 |
+
}
|
348 |
+
self::$isExistsPage = false;
|
349 |
+
|
350 |
+
return $this;
|
351 |
+
}
|
352 |
+
|
353 |
// FOR SALES //
|
354 |
/**
|
355 |
*
|
app/code/community/Simtech/Searchanise/Model/Queue.php
CHANGED
@@ -161,7 +161,7 @@ class Simtech_Searchanise_Model_Queue extends Mage_Core_Model_Abstract
|
|
161 |
{
|
162 |
$stores = Mage::helper('searchanise/ApiSe')->getStores($curStore);
|
163 |
|
164 |
-
foreach ($stores as $
|
165 |
$queue = Mage::getModel('searchanise/queue')->getCollection()->addFilter('store_id', $store->getId())->toArray();
|
166 |
|
167 |
if (!empty($queue['items'])) {
|
@@ -234,26 +234,25 @@ class Simtech_Searchanise_Model_Queue extends Mage_Core_Model_Abstract
|
|
234 |
return $collection->load()->delete();
|
235 |
}
|
236 |
|
237 |
-
public function addAction($action, $data =
|
238 |
{
|
239 |
-
if (in_array($action, self::$actionTypes))
|
240 |
-
{
|
241 |
if (!Mage::helper('searchanise/ApiSe')->checkParentPrivateKey()) {
|
242 |
return false;
|
243 |
}
|
244 |
|
245 |
$data = serialize((array)$data);
|
246 |
$data = array($data);
|
247 |
-
|
248 |
$stores = Mage::helper('searchanise/ApiSe')->getStores($curStore, $curStoreId);
|
249 |
-
|
250 |
if ($action == self::ACT_PREPARE_FULL_IMPORT && !empty($curStore)) {
|
251 |
// Truncate queue for all
|
252 |
Mage::getModel('searchanise/queue')->clearActions($curStore);
|
253 |
}
|
254 |
|
255 |
foreach ($data as $d) {
|
256 |
-
foreach ($stores as $
|
257 |
if (Mage::helper('searchanise/ApiSe')->getStatusModule($store) != 'Y') {
|
258 |
if (!in_array($action, self::$mainActionTypes)) {
|
259 |
continue;
|
@@ -272,13 +271,13 @@ class Simtech_Searchanise_Model_Queue extends Mage_Core_Model_Abstract
|
|
272 |
->delete();
|
273 |
}
|
274 |
|
275 |
-
$
|
276 |
'action' => $action,
|
277 |
'data' => $d,
|
278 |
'store_id' => $store->getId(),
|
279 |
);
|
280 |
-
|
281 |
-
$this->setData($
|
282 |
}
|
283 |
}
|
284 |
|
@@ -295,26 +294,62 @@ class Simtech_Searchanise_Model_Queue extends Mage_Core_Model_Abstract
|
|
295 |
// need get $currentIsActive for all stores because each store can have his value of IsActive for category.
|
296 |
$currentIsActive = $category->getIsActive();
|
297 |
$storeId = $category->getStoreId();
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
|
|
|
|
|
|
303 |
}
|
304 |
-
Mage::getModel('searchanise/queue')->addAction($action, $category->getId(), null, $storeId);
|
305 |
-
|
306 |
} elseif ($action == Simtech_Searchanise_Model_Queue::ACT_UPDATE_CATEGORIES) {
|
307 |
-
|
308 |
-
->
|
309 |
-
|
310 |
-
if ($prevCategory) {
|
311 |
$prevIsActive = $prevCategory->getIsActive();
|
312 |
if ($prevIsActive != $currentIsActive) {
|
313 |
// Delete need for all stores
|
314 |
Mage::getModel('searchanise/queue')->addAction(Simtech_Searchanise_Model_Queue::ACT_DELETE_CATEGORIES, $category->getId());
|
315 |
}
|
316 |
}
|
|
|
|
|
|
|
317 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
318 |
}
|
319 |
// end fixme
|
320 |
}
|
161 |
{
|
162 |
$stores = Mage::helper('searchanise/ApiSe')->getStores($curStore);
|
163 |
|
164 |
+
foreach ($stores as $keyStore => $store) {
|
165 |
$queue = Mage::getModel('searchanise/queue')->getCollection()->addFilter('store_id', $store->getId())->toArray();
|
166 |
|
167 |
if (!empty($queue['items'])) {
|
234 |
return $collection->load()->delete();
|
235 |
}
|
236 |
|
237 |
+
public function addAction($action, $data = null, $curStore = null, $curStoreId = null)
|
238 |
{
|
239 |
+
if (in_array($action, self::$actionTypes)) {
|
|
|
240 |
if (!Mage::helper('searchanise/ApiSe')->checkParentPrivateKey()) {
|
241 |
return false;
|
242 |
}
|
243 |
|
244 |
$data = serialize((array)$data);
|
245 |
$data = array($data);
|
246 |
+
|
247 |
$stores = Mage::helper('searchanise/ApiSe')->getStores($curStore, $curStoreId);
|
248 |
+
|
249 |
if ($action == self::ACT_PREPARE_FULL_IMPORT && !empty($curStore)) {
|
250 |
// Truncate queue for all
|
251 |
Mage::getModel('searchanise/queue')->clearActions($curStore);
|
252 |
}
|
253 |
|
254 |
foreach ($data as $d) {
|
255 |
+
foreach ($stores as $keyStore => $store) {
|
256 |
if (Mage::helper('searchanise/ApiSe')->getStatusModule($store) != 'Y') {
|
257 |
if (!in_array($action, self::$mainActionTypes)) {
|
258 |
continue;
|
271 |
->delete();
|
272 |
}
|
273 |
|
274 |
+
$queueData = array(
|
275 |
'action' => $action,
|
276 |
'data' => $d,
|
277 |
'store_id' => $store->getId(),
|
278 |
);
|
279 |
+
|
280 |
+
$this->setData($queueData)->save();
|
281 |
}
|
282 |
}
|
283 |
|
294 |
// need get $currentIsActive for all stores because each store can have his value of IsActive for category.
|
295 |
$currentIsActive = $category->getIsActive();
|
296 |
$storeId = $category->getStoreId();
|
297 |
+
$prevCategory = Mage::getModel('catalog/category')
|
298 |
+
->setStoreId($category->getStoreId())
|
299 |
+
->load($category->getId());
|
300 |
+
|
301 |
+
if ($action == Simtech_Searchanise_Model_Queue::ACT_DELETE_CATEGORIES) {
|
302 |
+
if ($prevCategory && $prevCategory->getIsActive()) {
|
303 |
+
// Delete in all stores
|
304 |
+
Mage::getModel('searchanise/queue')->addAction($action, $category->getId());
|
305 |
}
|
|
|
|
|
306 |
} elseif ($action == Simtech_Searchanise_Model_Queue::ACT_UPDATE_CATEGORIES) {
|
307 |
+
if ($currentIsActive) {
|
308 |
+
Mage::getModel('searchanise/queue')->addAction($action, $category->getId(), null, $storeId);
|
309 |
+
} else {
|
|
|
310 |
$prevIsActive = $prevCategory->getIsActive();
|
311 |
if ($prevIsActive != $currentIsActive) {
|
312 |
// Delete need for all stores
|
313 |
Mage::getModel('searchanise/queue')->addAction(Simtech_Searchanise_Model_Queue::ACT_DELETE_CATEGORIES, $category->getId());
|
314 |
}
|
315 |
}
|
316 |
+
}
|
317 |
+
// end fixme
|
318 |
+
}
|
319 |
|
320 |
+
return true;
|
321 |
+
}
|
322 |
+
|
323 |
+
public function addActionPage($page, $action = Simtech_Searchanise_Model_Queue::ACT_UPDATE_PAGES)
|
324 |
+
{
|
325 |
+
if ($page) {
|
326 |
+
// Fixme in the future
|
327 |
+
// need get $currentIsActive for all stores because each store can have his value of IsActive for page.
|
328 |
+
$currentIsActive = $page->getIsActive();
|
329 |
+
$storeId = $page->getStoreId();
|
330 |
+
$prevPage = Mage::getModel('cms/page')
|
331 |
+
// Fixme in the future
|
332 |
+
// need check for correct
|
333 |
+
->setStoreId($page->getStoreId())
|
334 |
+
// ->addStoreFilter($page->getStoreId())
|
335 |
+
// end fixme
|
336 |
+
->load($page->getId());
|
337 |
+
|
338 |
+
if ($action == Simtech_Searchanise_Model_Queue::ACT_DELETE_PAGES) {
|
339 |
+
if ($prevPage && $prevPage->getIsActive()) {
|
340 |
+
// Delete in all stores
|
341 |
+
Mage::getModel('searchanise/queue')->addAction($action, $page->getId());
|
342 |
+
}
|
343 |
+
} elseif ($action == Simtech_Searchanise_Model_Queue::ACT_UPDATE_PAGES) {
|
344 |
+
if ($currentIsActive) {
|
345 |
+
Mage::getModel('searchanise/queue')->addAction($action, $page->getId(), null, $storeId);
|
346 |
+
} else {
|
347 |
+
$prevIsActive = $prevPage->getIsActive();
|
348 |
+
if ($prevIsActive != $currentIsActive) {
|
349 |
+
// Delete need for all stores
|
350 |
+
Mage::getModel('searchanise/queue')->addAction(Simtech_Searchanise_Model_Queue::ACT_DELETE_PAGES, $page->getId());
|
351 |
+
}
|
352 |
+
}
|
353 |
}
|
354 |
// end fixme
|
355 |
}
|
app/code/community/Simtech/Searchanise/controllers/InfoController.php
CHANGED
@@ -24,6 +24,8 @@ class Simtech_Searchanise_InfoController extends Mage_Core_Controller_Front_Acti
|
|
24 |
const PRODUCT_IDS = 'product_ids';
|
25 |
const CATEGORY_ID = 'category_id';
|
26 |
const CATEGORY_IDS = 'category_ids';
|
|
|
|
|
27 |
const BY_ITEMS = 'by_items';
|
28 |
const PARENT_PRIVATE_KEY = 'parent_private_key';
|
29 |
|
@@ -76,6 +78,8 @@ class Simtech_Searchanise_InfoController extends Mage_Core_Controller_Front_Acti
|
|
76 |
$productIds = $this->getRequest()->getParam(self::PRODUCT_IDS);
|
77 |
$categoryId = $this->getRequest()->getParam(self::CATEGORY_ID);
|
78 |
$categoryIds = $this->getRequest()->getParam(self::CATEGORY_IDS);
|
|
|
|
|
79 |
$byItems = $this->getRequest()->getParam(self::BY_ITEMS);
|
80 |
if ($byItems == 'Y') {
|
81 |
Mage::helper('searchanise/ApiProducts')->setIsGetProductsByItems(true);
|
@@ -94,6 +98,7 @@ class Simtech_Searchanise_InfoController extends Mage_Core_Controller_Front_Acti
|
|
94 |
|
95 |
$productIds = $productId ? $productId : ($productIds ? explode(',', $productIds) : 0);
|
96 |
$categoryIds = $categoryId ? $categoryId : ($categoryIds ? explode(',', $categoryIds) : 0);
|
|
|
97 |
|
98 |
$store = null;
|
99 |
if (!empty($storeId)) {
|
@@ -142,7 +147,7 @@ class Simtech_Searchanise_InfoController extends Mage_Core_Controller_Front_Acti
|
|
142 |
} elseif ($resync) {
|
143 |
Mage::helper('searchanise/ApiSe')->queueImport($store);
|
144 |
|
145 |
-
} elseif (!empty($productIds) || !empty($categoryIds)) {
|
146 |
if (!$categoryIds) {
|
147 |
$categoryIds = Simtech_Searchanise_Model_Queue::NOT_DATA;
|
148 |
}
|
@@ -151,6 +156,7 @@ class Simtech_Searchanise_InfoController extends Mage_Core_Controller_Front_Acti
|
|
151 |
'items' => Mage::helper('searchanise/ApiProducts')->generateProductsFeed($productIds, $store, $checkData),
|
152 |
'schema' => Mage::helper('searchanise/ApiProducts')->getSchema(Simtech_Searchanise_Model_Queue::NOT_DATA, $store),
|
153 |
'categories' => Mage::helper('searchanise/ApiCategories')->generateCategoriesFeed($categoryIds, $store, $checkData),
|
|
|
154 |
);
|
155 |
|
156 |
if ($visual) {
|
24 |
const PRODUCT_IDS = 'product_ids';
|
25 |
const CATEGORY_ID = 'category_id';
|
26 |
const CATEGORY_IDS = 'category_ids';
|
27 |
+
const PAGE_ID = 'page_id';
|
28 |
+
const PAGE_IDS = 'page_ids';
|
29 |
const BY_ITEMS = 'by_items';
|
30 |
const PARENT_PRIVATE_KEY = 'parent_private_key';
|
31 |
|
78 |
$productIds = $this->getRequest()->getParam(self::PRODUCT_IDS);
|
79 |
$categoryId = $this->getRequest()->getParam(self::CATEGORY_ID);
|
80 |
$categoryIds = $this->getRequest()->getParam(self::CATEGORY_IDS);
|
81 |
+
$pageId = $this->getRequest()->getParam(self::PAGE_ID);
|
82 |
+
$pageIds = $this->getRequest()->getParam(self::PAGE_IDS);
|
83 |
$byItems = $this->getRequest()->getParam(self::BY_ITEMS);
|
84 |
if ($byItems == 'Y') {
|
85 |
Mage::helper('searchanise/ApiProducts')->setIsGetProductsByItems(true);
|
98 |
|
99 |
$productIds = $productId ? $productId : ($productIds ? explode(',', $productIds) : 0);
|
100 |
$categoryIds = $categoryId ? $categoryId : ($categoryIds ? explode(',', $categoryIds) : 0);
|
101 |
+
$pageIds = $pageId ? $pageId : ($pageIds ? explode(',', $pageIds) : 0);
|
102 |
|
103 |
$store = null;
|
104 |
if (!empty($storeId)) {
|
147 |
} elseif ($resync) {
|
148 |
Mage::helper('searchanise/ApiSe')->queueImport($store);
|
149 |
|
150 |
+
} elseif (!empty($productIds) || !empty($categoryIds) || !empty($pageIds)) {
|
151 |
if (!$categoryIds) {
|
152 |
$categoryIds = Simtech_Searchanise_Model_Queue::NOT_DATA;
|
153 |
}
|
156 |
'items' => Mage::helper('searchanise/ApiProducts')->generateProductsFeed($productIds, $store, $checkData),
|
157 |
'schema' => Mage::helper('searchanise/ApiProducts')->getSchema(Simtech_Searchanise_Model_Queue::NOT_DATA, $store),
|
158 |
'categories' => Mage::helper('searchanise/ApiCategories')->generateCategoriesFeed($categoryIds, $store, $checkData),
|
159 |
+
'pages' => Mage::helper('searchanise/ApiPages')->generatePagesFeed($pageIds, $store, $checkData),
|
160 |
);
|
161 |
|
162 |
if ($visual) {
|
app/code/community/Simtech/Searchanise/etc/config.xml
CHANGED
@@ -15,7 +15,7 @@
|
|
15 |
<config>
|
16 |
<modules>
|
17 |
<Simtech_Searchanise>
|
18 |
-
<version>3.0.
|
19 |
</Simtech_Searchanise>
|
20 |
</modules>
|
21 |
<frontend>
|
@@ -412,7 +412,7 @@
|
|
412 |
</rating>
|
413 |
</observers>
|
414 |
</catalog_entity_attribute_delete_after>
|
415 |
-
<!--
|
416 |
<catalog_category_delete_before>
|
417 |
<observers>
|
418 |
<rating>
|
@@ -437,6 +437,31 @@
|
|
437 |
</rating>
|
438 |
</observers>
|
439 |
</catalog_category_save_after>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
440 |
<!-- END CATALOG-->
|
441 |
<!-- SALES -->
|
442 |
<!-- products -->
|
@@ -578,6 +603,7 @@
|
|
578 |
<ajax_async_timeout>1</ajax_async_timeout>
|
579 |
<products_per_pass>100</products_per_pass>
|
580 |
<categories_per_pass>500</categories_per_pass>
|
|
|
581 |
<max_error_count>25</max_error_count>
|
582 |
<max_processing_thread>3</max_processing_thread>
|
583 |
<max_processing_time>720</max_processing_time>
|
15 |
<config>
|
16 |
<modules>
|
17 |
<Simtech_Searchanise>
|
18 |
+
<version>3.0.2</version>
|
19 |
</Simtech_Searchanise>
|
20 |
</modules>
|
21 |
<frontend>
|
412 |
</rating>
|
413 |
</observers>
|
414 |
</catalog_entity_attribute_delete_after>
|
415 |
+
<!-- categories -->
|
416 |
<catalog_category_delete_before>
|
417 |
<observers>
|
418 |
<rating>
|
437 |
</rating>
|
438 |
</observers>
|
439 |
</catalog_category_save_after>
|
440 |
+
<!-- pages -->
|
441 |
+
<cms_page_delete_before>
|
442 |
+
<observers>
|
443 |
+
<rating>
|
444 |
+
<class>searchanise/observer</class>
|
445 |
+
<method>cmsPageDeleteBefore</method>
|
446 |
+
</rating>
|
447 |
+
</observers>
|
448 |
+
</cms_page_delete_before>
|
449 |
+
<cms_page_save_before>
|
450 |
+
<observers>
|
451 |
+
<rating>
|
452 |
+
<class>searchanise/observer</class>
|
453 |
+
<method>cmsPageSaveBefore</method>
|
454 |
+
</rating>
|
455 |
+
</observers>
|
456 |
+
</cms_page_save_before>
|
457 |
+
<cms_page_save_after>
|
458 |
+
<observers>
|
459 |
+
<rating>
|
460 |
+
<class>searchanise/observer</class>
|
461 |
+
<method>cmsPageSaveAfter</method>
|
462 |
+
</rating>
|
463 |
+
</observers>
|
464 |
+
</cms_page_save_after>
|
465 |
<!-- END CATALOG-->
|
466 |
<!-- SALES -->
|
467 |
<!-- products -->
|
603 |
<ajax_async_timeout>1</ajax_async_timeout>
|
604 |
<products_per_pass>100</products_per_pass>
|
605 |
<categories_per_pass>500</categories_per_pass>
|
606 |
+
<pages_per_pass>50</pages_per_pass>
|
607 |
<max_error_count>25</max_error_count>
|
608 |
<max_processing_thread>3</max_processing_thread>
|
609 |
<max_processing_time>720</max_processing_time>
|
app/code/community/Simtech/Searchanise/etc/config_without_search.xml
CHANGED
@@ -15,7 +15,7 @@
|
|
15 |
<config>
|
16 |
<modules>
|
17 |
<Simtech_Searchanise>
|
18 |
-
<version>3.0.
|
19 |
</Simtech_Searchanise>
|
20 |
</modules>
|
21 |
<frontend>
|
@@ -412,7 +412,7 @@
|
|
412 |
</rating>
|
413 |
</observers>
|
414 |
</catalog_entity_attribute_delete_after>
|
415 |
-
<!--
|
416 |
<catalog_category_delete_before>
|
417 |
<observers>
|
418 |
<rating>
|
@@ -437,6 +437,31 @@
|
|
437 |
</rating>
|
438 |
</observers>
|
439 |
</catalog_category_save_after>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
440 |
<!-- END CATALOG-->
|
441 |
<!-- SALES -->
|
442 |
<!-- products -->
|
@@ -578,6 +603,7 @@
|
|
578 |
<ajax_async_timeout>1</ajax_async_timeout>
|
579 |
<products_per_pass>100</products_per_pass>
|
580 |
<categories_per_pass>500</categories_per_pass>
|
|
|
581 |
<max_error_count>25</max_error_count>
|
582 |
<max_processing_thread>3</max_processing_thread>
|
583 |
<max_processing_time>720</max_processing_time>
|
15 |
<config>
|
16 |
<modules>
|
17 |
<Simtech_Searchanise>
|
18 |
+
<version>3.0.2</version>
|
19 |
</Simtech_Searchanise>
|
20 |
</modules>
|
21 |
<frontend>
|
412 |
</rating>
|
413 |
</observers>
|
414 |
</catalog_entity_attribute_delete_after>
|
415 |
+
<!-- categories -->
|
416 |
<catalog_category_delete_before>
|
417 |
<observers>
|
418 |
<rating>
|
437 |
</rating>
|
438 |
</observers>
|
439 |
</catalog_category_save_after>
|
440 |
+
<!-- pages -->
|
441 |
+
<cms_page_delete_before>
|
442 |
+
<observers>
|
443 |
+
<rating>
|
444 |
+
<class>searchanise/observer</class>
|
445 |
+
<method>cmsPageDeleteBefore</method>
|
446 |
+
</rating>
|
447 |
+
</observers>
|
448 |
+
</cms_page_delete_before>
|
449 |
+
<cms_page_save_before>
|
450 |
+
<observers>
|
451 |
+
<rating>
|
452 |
+
<class>searchanise/observer</class>
|
453 |
+
<method>cmsPageSaveBefore</method>
|
454 |
+
</rating>
|
455 |
+
</observers>
|
456 |
+
</cms_page_save_before>
|
457 |
+
<cms_page_save_after>
|
458 |
+
<observers>
|
459 |
+
<rating>
|
460 |
+
<class>searchanise/observer</class>
|
461 |
+
<method>cmsPageSaveAfter</method>
|
462 |
+
</rating>
|
463 |
+
</observers>
|
464 |
+
</cms_page_save_after>
|
465 |
<!-- END CATALOG-->
|
466 |
<!-- SALES -->
|
467 |
<!-- products -->
|
603 |
<ajax_async_timeout>1</ajax_async_timeout>
|
604 |
<products_per_pass>100</products_per_pass>
|
605 |
<categories_per_pass>500</categories_per_pass>
|
606 |
+
<pages_per_pass>50</pages_per_pass>
|
607 |
<max_error_count>25</max_error_count>
|
608 |
<max_processing_thread>3</max_processing_thread>
|
609 |
<max_processing_time>720</max_processing_time>
|
package.xml
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Simtech_Searchanise</name>
|
4 |
-
<version>3.0.
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://docs.searchanise.com/connector_addon/license_agreement.html">Commercial license: http://docs.searchanise.com/connector_addon/license_agreement.html</license>
|
7 |
<channel>community</channel>
|
@@ -10,11 +10,12 @@
|
|
10 |
<description>Searchanise is a free SaaS solution providing fast and smart search for online stores. It provides rapid search results and instant search suggestions presented in a fancy and customizable widget.
|
11 |

|
12 |
With the help of Searchanise Connector Add-on you will be able to connect your store to the service and start using the search widget in no time. Power up your store right now!</description>
|
13 |
-
<notes>[
|
|
|
14 |
<authors><author><name>Simbirsk Technologies, Ltd.</name><user>searchanise</user><email>sales@searchanise.com</email></author></authors>
|
15 |
-
<date>2014-02-
|
16 |
-
<time>
|
17 |
-
<contents><target name="magecommunity"><dir name="Simtech"><dir name="Searchanise"><dir name="Block"><file name="Async.php" hash="bc97c98da15f5abbc1d8922ca477dc6d"/><file name="Autocomplete.php" hash="efc89ac3f897be3bc307fba6a36778f0"/><file name="Jsinit.php" hash="3cb0a3bd02858a6ce81d14dbc7b6042f"/><dir name="Product"><dir name="List"><file name="Toolbar.php" hash="759854378cb8c35c37a8a7f44076194f"/></dir><file name="Result.php" hash="4e767e273ee21a38332ac226af878291"/></dir><file name="Result.php" hash="dec7b27ab9511c956680eb60eba9b95e"/></dir><dir name="Helper"><file name="ApiCategories.php" hash="
|
18 |
<compatible/>
|
19 |
<dependencies><required><php><min>5.2.13</min><max>6.0.0</max></php></required></dependencies>
|
20 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Simtech_Searchanise</name>
|
4 |
+
<version>3.0.2</version>
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://docs.searchanise.com/connector_addon/license_agreement.html">Commercial license: http://docs.searchanise.com/connector_addon/license_agreement.html</license>
|
7 |
<channel>community</channel>
|
10 |
<description>Searchanise is a free SaaS solution providing fast and smart search for online stores. It provides rapid search results and instant search suggestions presented in a fancy and customizable widget.
|
11 |

|
12 |
With the help of Searchanise Connector Add-on you will be able to connect your store to the service and start using the search widget in no time. Power up your store right now!</description>
|
13 |
+
<notes>[+] Content search support added.<br />
|
14 |
+
[!] Invalid data could be submitted on category change. Fixed.</notes>
|
15 |
<authors><author><name>Simbirsk Technologies, Ltd.</name><user>searchanise</user><email>sales@searchanise.com</email></author></authors>
|
16 |
+
<date>2014-02-19</date>
|
17 |
+
<time>12:59:12</time>
|
18 |
+
<contents><target name="magecommunity"><dir name="Simtech"><dir name="Searchanise"><dir name="Block"><file name="Async.php" hash="bc97c98da15f5abbc1d8922ca477dc6d"/><file name="Autocomplete.php" hash="efc89ac3f897be3bc307fba6a36778f0"/><file name="Jsinit.php" hash="3cb0a3bd02858a6ce81d14dbc7b6042f"/><dir name="Product"><dir name="List"><file name="Toolbar.php" hash="759854378cb8c35c37a8a7f44076194f"/></dir><file name="Result.php" hash="4e767e273ee21a38332ac226af878291"/></dir><file name="Result.php" hash="dec7b27ab9511c956680eb60eba9b95e"/></dir><dir name="Helper"><file name="ApiCategories.php" hash="a0297c7495c503fed7dd858903fabde7"/><file name="ApiPages.php" hash="65aa424848ff62b2aa883043ab84f56c"/><file name="ApiProducts.php" hash="8164c75f2e2000d032a8510614e4be50"/><file name="ApiSe.php" hash="e01de5681673953cc7144e1a95b2c3eb"/><file name="Data.php" hash="d4925c397d8b821b47be87a4d377930a"/></dir><dir name="Model"><file name="Advanced.php" hash="deb3ae5193e0aee50b94360b1833ac82"/><dir name="Config"><file name="Data.php" hash="ddc558d22208f0ebc1e4378c9d050022"/></dir><file name="Config.php" hash="00ca3c7955f3ff2283c636a2074b6f03"/><dir name="Import"><dir name="Entity"><file name="Product.php" hash="4997af528b36f0f576d1c01402e14b03"/></dir></dir><dir name="Layer"><dir name="Filter"><file name="Category.php" hash="e290ab29f2d50e1acbbbb37496150ea4"/><file name="Price.php" hash="743887b32bf012274ad8a371fff96411"/></dir></dir><file name="Layer.php" hash="3e8c975d649ae6e20fcc69d35779c97c"/><file name="LayerCatalogSearch.php" hash="42058e0552719902f3f40f91e816b460"/><dir name="Mysql4"><dir name="Advanced"><file name="Collection.php" hash="dd8c6f3cbb0621a5a7320f3104e68da6"/></dir><dir name="Config"><file name="Collection.php" hash="470218c1eb3f1cc1ca0e6d0e93e1b097"/></dir><file name="Config.php" hash="c95dc8ecd7ab4f955b6eaf4710ab960e"/><dir name="Fulltext"><file name="Collection.php" hash="5646955503a90020f87cfd861ac07e73"/></dir><dir name="Product"><file name="Collection.php" hash="28b478eb328502ce03e389404d9f54b5"/><file name="CollectionTag.php" hash="ea06ec75ee4d083f2b4232c5fe298f00"/></dir><dir name="Queue"><file name="Collection.php" hash="30ca0f8640bdc443deb94cd2e71010c8"/></dir><file name="Queue.php" hash="286351623e8f011a21519f8d9c3e3151"/><file name="Store.php" hash="0126a4291d7dad6641bf59abb0f64cc4"/></dir><file name="Observer.php" hash="009d7bbb28ae6647db4fd9119a280194"/><file name="Queue.php" hash="f862b207d2dc9bb7f56c829b8a1480fe"/><file name="Request.php" hash="897d53117d7d0e11932e77daaf8b639e"/><dir name="Resource"><dir name="Advanced"><file name="Collection.php" hash="6744555254ba1c57f482504b5f16012a"/></dir><dir name="Eav"><dir name="Mysql4"><dir name="Layer"><dir name="Filter"><file name="Attribute.php" hash="05320757b9289edac4f15230cd06c0e1"/><file name="Price.php" hash="ed4e21a18c552e3a92b21ff6e8bc5d61"/></dir></dir><dir name="Product"><file name="Action.php" hash="006e3c8c775cf31a8b9c66fb934c9d2d"/></dir></dir></dir><dir name="Fulltext"><file name="Collection.php" hash="273467b2e39649fcd0a8eede59c5ab98"/></dir><dir name="Layer"><dir name="Filter"><file name="Attribute.php" hash="643a513735ac2a2ac9fba08ff1fa79a0"/><file name="Price.php" hash="15d7ab510b37655a148e077dcece13df"/></dir></dir><dir name="Product"><file name="Collection.php" hash="b7c9a1c2fc24ecf78a32fd0d9d46b120"/><file name="CollectionTag.php" hash="60f12d27d78426a8e04e01d2cbdadb48"/></dir><file name="Store.php" hash="dee8bb23b7fe48dc55e46e93f583699a"/></dir><file name="Searchanise.php" hash="0a03a35854470a310f075298c9a1abf2"/><dir name="System"><dir name="Config"><dir name="Source"><dir name="Searchanise"><file name="TypeAsync.php" hash="11d1aa481094ccbeab365b1fed33440d"/></dir></dir></dir></dir><dir name="Tag"><file name="Relation.php" hash="598f81fd8b2ac77baf24211c2ed03e55"/></dir></dir><dir name="controllers"><file name="AdvancedController.php" hash="5ea4f7fb3362d720462dc0a8e1f1497b"/><file name="AsyncController.php" hash="f589349f353e2de8c31155b2025b8bea"/><file name="CategoryController.php" hash="06eac1ad4730d42379f6bc6aae097427"/><file name="IndexController.php" hash="e3234ca51a7669741e29ff7c38789989"/><file name="InfoController.php" hash="9dc96775d093c25bc151a3ad8a50cdb6"/><file name="OptionsController.php" hash="46b8e49dd1026a5e07410b51d101d498"/><file name="ProductController.php" hash="4cf4e991446a36ea34b7c1d350971e1a"/><file name="ResultController.php" hash="2c1d838a2897ffcbb8bc61743254e934"/><file name="ResyncController.php" hash="0612f929d375427326821dfc12186be8"/><file name="SignupController.php" hash="80f87a63d6272f98a068dde35f1d140e"/></dir><dir name="etc"><file name="config.xml" hash="e5e6cb51f68da83aab7ec0f1f8aecd31"/><file name="config_without_search.xml" hash="550d0d6139b67ef9f37169416db6b7d2"/><file name="system.xml" hash="a006341e693571d11efaa9d289ebf7fa"/></dir><dir name="sql"><dir name="searchanise_setup"><file name="mysql4-install-0.1.0.php" hash="754324c8783e9cc24de86396e1587e73"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="searchanise"><file name="dashboard.phtml" hash="0ec8814b915e8594b019062c071cc485"/></dir></dir><dir name="layout"><file name="searchanise.xml" hash="68baa611d05db05f8816ea2a8260e961"/></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="searchanise.xml" hash="5e904fee02cbd42324a297d513b9f582"/></dir></dir></dir><dir name="default"><dir name="default"><dir name="template"><dir name="catalogsearch"><file name="form.mini.phtml" hash="fcf8e06e66801a36c96f20ca5d187123"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Simtech_Searchanise.xml" hash="04148681a6648bd370ab62140cbf2ad9"/></dir></target><target name="magelocale"><dir name="en_US"><file name="Simtech_Searchanise.csv" hash="1bdb7fddc596dac1460bc3054c425187"/></dir></target></contents>
|
19 |
<compatible/>
|
20 |
<dependencies><required><php><min>5.2.13</min><max>6.0.0</max></php></required></dependencies>
|
21 |
</package>
|