Skip to content

Commit 2f171b3

Browse files
committed
Merge remote-tracking branch 'origin/master' into develop
2 parents d07ea82 + 3e2e5f0 commit 2f171b3

File tree

8 files changed

+183
-29
lines changed

8 files changed

+183
-29
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"homepage": "https://github.com/integer-net/solr-magento1",
66
"require": {
77
"aoepeople/aoe_layoutconditions": "~1.0.0",
8-
"integer-net/solr-base": "~1.0.0"
8+
"integer-net/solr-base": "~2.0.0"
99
},
1010
"require-dev": {
1111
"ecomdev/ecomdev_phpunit": "dev-dev",

doc/release-notes.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
IntegerNet_Solr Free for Magento 1
2+
===============
3+
Release Notes
4+
5+
Version 1.7.3 (May 18, 2017)
6+
---------------
7+
8+
- Bugfix regarding RWD theme
9+
10+
Version 1.7.2 (May 16, 2017)
11+
---------------
12+
13+
- Add slicing functionality (see src/shell/integernet-solr.php)
14+
- Fix bug with indexing multistore products with activated flat catalog
15+
- Exclude items with zero counts from filter items count calculation (thanks @tim-bezhashvyly!)
16+
- Fallback to Magento if category is excluded from Solr index (thanks @tim-bezhashvyly!)
17+
- Move files regarding autosuggest to Pro module
18+
19+
Version 1.7.1 (May 3, 2017)
20+
---------------
21+
22+
- Support Indexing of Bundle Child Products
23+
- Optimization of Search Results for search queries containing numbers
24+
- Bugfix regarding Flat Product Setting
25+
- Bugfix regarding Flat Category Setting
26+
- Bugfix regarding Re-Initialization of MySQL Connection
27+
- Bugfix regarding duplicate Layout Update (thanks @tim-bezhashvyly!)
28+
29+
Version 1.7.0 (Oct 12, 2016)
30+
---------------
31+
32+
- First public release of IntegerNet_Solr Free
33+
34+
Version 1.6.0 (Aug 1, 2016)
35+
---------------
36+
37+
- Improved search algorithm, e.g. for search terms containing both words and numbers
38+
- Category and CMS pages in autosuggest results
39+
- More configuration options for filters
40+
- Improved compatibility with other third party extensions
41+
42+
Version 1.5.0 (Mar 7, 2016)
43+
---------------
44+
45+
This is a completely refactored version. Plus, we added quite a number of new features, improving usability, search results and SEO:
46+
47+
- Select multiple filter values
48+
- Horizontal display of filters on search result pages
49+
- Select per category which filters shall be available
50+
- Configurable meta robots tag (NOINDEX, NOFOLLOW) for search result pages, filtered search results and filtered category pages
51+
- Adjustable boost for products in search results if they are in a category whose name matches the search term
52+
- Direct redirects to a product or category page if the search term is an exact match with the product name, SKU, category name, or a different attribute of your choice

src/app/code/community/IntegerNet/Solr/Block/Result/Layer/View.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ protected function _getFilter($attribute, $attributeFacets)
134134
{
135135
$filter = new Varien_Object();
136136
$filter->setName($attribute->getStoreLabel());
137-
$filter->setItemsCount(sizeof($attributeFacets));
137+
$filter->setItemsCount(sizeof(array_filter($attributeFacets)));
138138
$filter->setIdentifier($attribute->getAttributeCode());
139139
$filter->setHtml(
140140
$this->_getFilterBlock()
@@ -155,7 +155,7 @@ protected function _getIntervalFilter($attribute, $attributeFacetData)
155155
{
156156
$filter = new Varien_Object();
157157
$filter->setName($attribute->getStoreLabel());
158-
$filter->setItemsCount(sizeof($attributeFacetData));
158+
$filter->setItemsCount(sizeof(array_filter($attributeFacetData)));
159159
$filter->setIdentifier($attribute->getAttributeCode());
160160
$filter->setHtml(
161161
$this->_getFilterBlock()
@@ -176,7 +176,7 @@ protected function _getRangeFilter($attribute, $attributeFacetData)
176176
{
177177
$filter = new Varien_Object();
178178
$filter->setName($attribute->getStoreLabel());
179-
$filter->setItemsCount(sizeof($attributeFacetData['counts']));
179+
$filter->setItemsCount(sizeof(array_filter($attributeFacetData['counts'])));
180180
$filter->setIdentifier($attribute->getAttributeCode());
181181
$filter->setHtml(
182182
$this->_getFilterBlock()
@@ -196,7 +196,7 @@ protected function _getCategoryFilter($categoryFacets)
196196
{
197197
$filter = new Varien_Object();
198198
$filter->setName(Mage::helper('catalog')->__('Category'));
199-
$filter->setItemsCount(sizeof($categoryFacets));
199+
$filter->setItemsCount(sizeof(array_filter($categoryFacets)));
200200
$filter->setIdentifier('category');
201201

202202
/** @var IntegerNet_Solr_Block_Result_Layer_Filter $filterBlock */
@@ -251,4 +251,4 @@ protected function _getFilterBlock()
251251
{
252252
return $this->getChild('filter')->reset();
253253
}
254-
}
254+
}

src/app/code/community/IntegerNet/Solr/Model/Bridge/ProductRepository.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,25 @@ function($parentId, $childrenIds) {
6666
}
6767

6868
/**
69+
* @param null|int $sliceId
70+
* @param null|int $totalNumberSlices
6971
* @return int[]
7072
*/
71-
public function getAllProductIds()
73+
public function getAllProductIds($sliceId = null, $totalNumberSlices = null)
7274
{
75+
// Fixes a bug with flat product collections called for different stores, see https://magento.stackexchange.com/q/30956/2207
76+
Mage::unregister('_resource_singleton/catalog/product_flat');
77+
7378
/** @var $productCollection Mage_Catalog_Model_Resource_Product_Collection */
7479
$productCollection = Mage::getResourceModel('catalog/product_collection');
80+
81+
if ((!is_null($sliceId)) && (!is_null($totalNumberSlices))) {
82+
if ($sliceId == $totalNumberSlices) {
83+
$sliceId = 0;
84+
}
85+
$productCollection->getSelect()->where('e.entity_id % ' . intval($totalNumberSlices) . ' = ' . intval($sliceId));
86+
}
87+
7588
return $productCollection->getAllIds();
7689
}
7790

src/app/code/community/IntegerNet/Solr/etc/config.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<config>
33
<modules>
44
<IntegerNet_Solr>
5-
<version>1.7.1</version>
5+
<version>1.7.3</version>
66
<version_suffix />
77
</IntegerNet_Solr>
88
</modules>

src/app/design/frontend/base/default/layout/integernet/solr.xml

100644100755
Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,6 @@
11
<?xml version="1.0"?>
22
<layout version="0.1.0">
33

4-
<default>
5-
<reference name="head">
6-
<action method="addCss" ifconfig="integernet_solr/general/is_active">
7-
<stylesheet>integernet/solr/css/autosuggest.css</stylesheet>
8-
</action>
9-
</reference>
10-
</default>
11-
124
<catalogsearch_result_index>
135
<reference name="head">
146
<action method="addItem" ifconfig="integernet_solr/general/is_active">

src/app/design/frontend/rwd/default/layout/integernet/solr.xml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,6 @@
11
<?xml version="1.0"?>
22
<layout version="0.1.0">
33

4-
<default>
5-
<reference name="head">
6-
<action method="addCss" ifconfig="integernet_solr/general/is_active">
7-
<stylesheet>integernet/solr/css/autosuggest.css</stylesheet>
8-
</action>
9-
</reference>
10-
</default>
11-
124
<catalogsearch_result_index>
135
<reference name="head">
146
<action method="addItem" ifconfig="integernet_solr/general/is_active">
@@ -115,9 +107,6 @@
115107
<action method="setListModes"/>
116108
<action method="setListCollection"/>
117109
</reference>
118-
<reference name="before_body_end">
119-
<block type="integernet_solr/js" name="solr.js" template="integernet/solr/js.phtml" />
120-
</reference>
121110
</catalog_category_layered>
122111

123112
<catalog_category_default>

src/shell/integernet-solr.php

Lines changed: 110 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,73 @@ public function run()
6767
echo $e->getMessage() . "\n";
6868
}
6969

70+
} else if ($this->getArg('reindex_slice')) {
71+
$storeIdentifiers = $this->getArg('stores');
72+
if (!$storeIdentifiers) {
73+
$storeIdentifiers = 'all';
74+
}
75+
$storeIds = $this->_getStoreIds($storeIdentifiers);
76+
77+
$autoloader = new IntegerNet_Solr_Helper_Autoloader();
78+
$autoloader->createAndRegister();
79+
80+
try {
81+
$sliceArg = $this->getArg('slice');
82+
$this->_checkSliceArgument($sliceArg);
83+
list($sliceId, $totalNumberSlices) = explode('/', $sliceArg);
84+
85+
$indexer = Mage::helper('integernet_solr')->factory()->getProductIndexer();
86+
87+
if ($this->getArg('use_swap_core')) {
88+
$indexer->activateSwapCore();
89+
}
90+
$indexer->reindex(null, false, $storeIds, $sliceId, $totalNumberSlices);
91+
if ($this->getArg('use_swap_core')) {
92+
$indexer->deactivateSwapCore();
93+
}
94+
95+
$storeIdsString = implode(', ', $storeIds);
96+
echo "Solr product index rebuilt for Stores {$storeIdsString}.\n";
97+
echo '(Slice ' . $sliceId . ' of ' . $totalNumberSlices . ')' . "\n";
98+
} catch (Exception $e) {
99+
echo $e->getMessage() . "\n";
100+
}
101+
102+
} else if ($this->getArg('clear')) {
103+
$storeIdentifiers = $this->getArg('stores');
104+
if (!$storeIdentifiers) {
105+
$storeIdentifiers = 'all';
106+
}
107+
$storeIds = $this->_getStoreIds($storeIdentifiers);
108+
$indexer = Mage::helper('integernet_solr')->factory()->getProductIndexer();
109+
if ($this->getArg('use_swap_core')) {
110+
$indexer->activateSwapCore();
111+
}
112+
foreach($storeIds as $storeId) {
113+
$indexer->clearIndex($storeId);
114+
}
115+
if ($this->getArg('use_swap_core')) {
116+
$indexer->deactivateSwapCore();
117+
}
118+
$storeIdsString = implode(', ', $storeIds);
119+
echo "Solr product index cleared for Stores {$storeIdsString}.\n";
120+
121+
} else if ($this->getArg('swap_cores')) {
122+
$storeIdentifiers = $this->getArg('stores');
123+
if (!$storeIdentifiers) {
124+
$storeIdentifiers = 'all';
125+
}
126+
$storeIds = $this->_getStoreIds($storeIdentifiers);
127+
$indexer = Mage::helper('integernet_solr')->factory()->getProductIndexer();
128+
try {
129+
$indexer->checkSwapCoresConfiguration($storeIds);
130+
$indexer->swapCores($storeIds);
131+
$storeIdsString = implode(', ', $storeIds);
132+
echo "Solr cores swapped for Stores {$storeIdsString}.\n";
133+
} catch (Exception $e) {
134+
echo $e->getMessage() . "\n";
135+
}
136+
70137
} else {
71138
echo $this->usageHelp();
72139
}
@@ -82,12 +149,27 @@ public function usageHelp()
82149
Usage: php -f integernet-solr.php -- [options]
83150
php -f integernet-solr.php -- reindex --stores de
84151
php -f integernet-solr.php -- reindex --stores all --emptyindex
152+
php -f integernet-solr.php -- reindex --stores 1 --slice 1/5 --use_swap_core
153+
php -f integernet-solr.php -- clear --stores 1
85154
86-
reindex reindex solr for given stores (see "stores" param)
87-
--stores <stores> reindex given stores (can be store id, store code, comma seperated. Or "all".) If not set, reindex all stores.
155+
reindex Reindex solr for given stores (see "stores" param)
156+
--stores <stores> Reindex given stores (can be store id, store code, comma seperated. Or "all".) If not set, reindex all stores.
88157
--emptyindex Force emptying the solr index for the given store(s). If not set, configured value is used.
89158
--noemptyindex Force not emptying the solr index for the given store(s). If not set, configured value is used.
90159
--types <types> Restrict indexing to certain entity types, i.e. "product", "category" or "page" (comma separated). Or "all". If not set, reindex products.
160+
161+
reindex_slice Reindex solr for given stores (see "stores" param). Use this if you want to index only a part of the products, i.e. for letting indexing run in parallel (for products only).
162+
--slice <number>/<total_number>, i.e. "1/5" or "2/5".
163+
--stores <stores> Reindex given stores (can be store id, store code, comma seperated. Or "all".) If not set, reindex all stores.
164+
--use_swap_core Use swap core for indexing instead of live solr core (only if configured correctly).
165+
166+
clear Clear solr product index for given stores (see "stores" param and "use_swap_core" param)
167+
--stores <stores> Reindex given stores (can be store id, store code, comma seperated. Or "all".) If not set, reindex all stores.
168+
--use_swap_core Use swap core for clearing instead of live solr core (only if configured correctly).
169+
170+
swap_cores Swap cores. This is useful if using slices (see above) after indexing with the "--use_swap_core" param; it's not needed otherwise.
171+
--stores <stores> Reindex given stores (can be store id, store code, comma seperated. Or "all".) If not set, reindex all stores.
172+
91173
help This help
92174
93175
USAGE;
@@ -149,6 +231,32 @@ protected function _useCmsIndexer()
149231
{
150232
return Mage::helper('core')->isModuleEnabled('IntegerNet_SolrPro') && Mage::getStoreConfigFlag('integernet_solr/cms/is_active');
151233
}
234+
235+
/**
236+
* @param string $sliceArg
237+
* @throws InvalidArgumentException
238+
*/
239+
protected function _checkSliceArgument($sliceArg)
240+
{
241+
if (!strlen($sliceArg)) {
242+
throw new InvalidArgumentException('The "slice" argument must be given.');
243+
}
244+
if (strpos($sliceArg, '/') < 1) {
245+
throw new InvalidArgumentException('The "slice" argument must be of format "1/5" or "20/20"');
246+
}
247+
list($sliceId, $totalNumberSlices) = explode('/', $sliceArg);
248+
$sliceId = intval($sliceId);
249+
$totalNumberSlices = intval($totalNumberSlices);
250+
if (!is_integer($sliceId) || !is_integer($totalNumberSlices)) {
251+
throw new InvalidArgumentException('The "slice" argument must be of format "1/5" or "20/20", only containing integer numbers before/after the slash.');
252+
}
253+
if ($totalNumberSlices < 2) {
254+
throw new InvalidArgumentException('The "slice" argument must be of format "1/5" or "20/20". The second number must be higher than 1.');
255+
}
256+
if ($sliceId < 1 || $sliceId > $totalNumberSlices) {
257+
throw new InvalidArgumentException('The "slice" argument must be of format "1/5" or "20/20". The first number is invalid, should be between 1 and the second number (including those).');
258+
}
259+
}
152260
}
153261

154262
$shell = new IntegerNet_Solr_Shell();

0 commit comments

Comments
 (0)