Skip to content

Commit

Permalink
Develop (#1169)
Browse files Browse the repository at this point in the history
  • Loading branch information
damcou committed Jun 29, 2020
1 parent 291b95b commit d8f95e8
Show file tree
Hide file tree
Showing 17 changed files with 1,114 additions and 195 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# CHANGE LOG

## 1.18.0

### Updates
- Update PHP Client to v 1.28.0 (#1162)
- Update copyQueryRules to use scopedCopyIndex method (#1166)
- Update README.md (#1167)

## 1.17.1

### Updates
Expand Down
26 changes: 19 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Algolia Search for Magento 1.6+
==================

![Latest version](https://img.shields.io/badge/latest-1.17.1-green.svg)
![Latest version](https://img.shields.io/badge/latest-1.18.0-green.svg)

[![Build Status](https://travis-ci.org/algolia/algoliasearch-magento.svg?branch=master)](https://travis-ci.org/algolia/algoliasearch-magento)
![PHP >= 5.3](https://img.shields.io/badge/php-%3E=5.3-green.svg)
Expand All @@ -14,15 +14,15 @@ Algolia Search for Magento 1.6+

-------

🔎 Are you a Magento engineer? [Join our team](https://www.algolia.com/careers#!?j=eed58660-f684-436d-a2ff-e9947d2b65a2) and help us deliver the best search solution for Magento stores!
🔎   **Need help?** Check out our [Troubleshooting Guide](https://www.algolia.com/doc/integration/magento-1/troubleshooting/data-indexes-queues/) and our [General FAQs](https://www.algolia.com/doc/integration/magento-1/troubleshooting/general-faq/). For feedback, bug reporting, or unresolved issues with the extension, please contact us at [[email protected]](mailto:[email protected]). Please include your Magento version, extension version, application ID, and steps to reproducing your issue. Add additional information like screenshots, screencasts, and error messages to help our team better troubleshoot your issues.

-------

- **Auto-completion menu:** Offer End-Users immediate access to your whole catalog from the dropdown menu, whatever your number of categories or attributes.
- **Autocompletion menu:** Offer End-Users immediate access to your whole catalog from the dropdown menu, whatever your number of categories or attributes.

- **Instant search results page:** Have your search results page, navigation and pagination updated in realtime, after each keystroke.
- **Instantsearch results page:** Have your search results page, navigation and pagination updated in realtime, after each keystroke.

Official website: [community.algolia.com/magento](https://community.algolia.com/magento).
Official website: [https://www.algolia.com/solutions/magento/](https://www.algolia.com/solutions/magento/).

*Note: if your store is running under Magento version 2, please check our [Algolia for Magento 2 extension](https://github.com/algolia/algoliasearch-magento-2).*

Expand All @@ -38,12 +38,12 @@ You can check out our [live demo](https://magento.algolia.com).
Documentation
--------------

Check out the [Algolia Search for Magento 1 documentation](https://community.algolia.com/magento/doc/m1/getting-started/).
Check out the [Algolia Search for Magento 1 documentation](https://www.algolia.com/doc/integration/magento-1/getting-started/quick-start/).

Installation
------------

Follow our [getting started guide](https://community.algolia.com/magento/doc/m1/getting-started/).
Follow our [getting started guide](https://www.algolia.com/doc/integration/magento-1/getting-started/quick-start/).

Contribute to the Extension
------------
Expand Down Expand Up @@ -101,3 +101,15 @@ $ cd /path/to/your/magento/directory
$ modman init
$ modman clone https://github.com/algolia/algoliasearch-magento.git
```

Need Help?
------------
Here are some helpful documentation to help with your issue:

- [General FAQs](https://www.algolia.com/doc/integration/magento-1/troubleshooting/general-faq/)
- [Troubleshooting Guide](https://www.algolia.com/doc/integration/magento-1/troubleshooting/data-indexes-queues/)
- [Indexing Queue](https://www.algolia.com/doc/integration/magento-1/how-it-works/indexing-queue/)
- [Frontend Custom Events](https://www.algolia.com/doc/integration/magento-1/customize/custom-front-end-events/)
- [Dispatched Backend Events](https://www.algolia.com/doc/integration/magento-1/customize/custom-back-end-events/)

For feedback, bug reporting, or unresolved issues with the extension, please contact us at [[email protected]](mailto:[email protected]). Please include your Magento version, extension version, application ID, and steps to reproducing your issue. Add additional information like screenshots, screencasts, and error messages to help our team better troubleshoot your issues.
35 changes: 5 additions & 30 deletions app/code/community/Algolia/Algoliasearch/Helper/Algoliahelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,40 +240,15 @@ public function copySynonyms($fromIndexName, $toIndexName)
/**
* @param $fromIndexName
* @param $toIndexName
*
* @throws \AlgoliaSearch\AlgoliaException
*/
public function copyQueryRules($fromIndexName, $toIndexName)
{
$fromIndex = $this->getIndex($fromIndexName);
$toIndex = $this->getIndex($toIndexName);

$queryRulesToSet = array();

$hitsPerPage = 100;
$page = 0;
do {
$fetchedQueryRules = $fromIndex->searchRules(array(
'page' => $page,
'hitsPerPage' => $hitsPerPage,
));

foreach ($fetchedQueryRules['hits'] as $hit) {
unset($hit['_highlightResult']);
$res = $this->getClient()->scopedCopyIndex($fromIndexName, $toIndexName, array('rules'), array(
'forwardToReplicas' => true,
'clearExistingRules' => true
));

$queryRulesToSet[] = $hit;
}

$page++;
} while (($page * $hitsPerPage) < $fetchedQueryRules['nbHits']);

if (empty($queryRulesToSet)) {
$res = $toIndex->clearRules(true);
} else {
$res = $toIndex->batchRules($queryRulesToSet, true, true);
}

$this->lastUsedIndexName = $toIndex;
$this->lastUsedIndexName = $toIndexName;
$this->lastTaskId = $res['taskID'];
}

Expand Down
2 changes: 1 addition & 1 deletion app/code/community/Algolia/Algoliasearch/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<config>
<modules>
<Algolia_Algoliasearch>
<version>1.17.1</version>
<version>1.18.0</version>
</Algolia_Algoliasearch>
</modules>
<frontend>
Expand Down
2 changes: 1 addition & 1 deletion app/code/community/Algolia/Algoliasearch/etc/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<algoliasearch translate="label" module="algoliasearch">
<label>
<![CDATA[
Algolia Search 1.17.1
Algolia Search 1.18.0
<style>
.algoliasearch-admin-menu span {
padding-left: 38px !important;
Expand Down
2 changes: 1 addition & 1 deletion app/etc/modules/Algolia_Algoliasearch.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<Algolia_Algoliasearch>
<active>true</active>
<codePool>community</codePool>
<version>1.17.1</version>
<version>1.18.0</version>
</Algolia_Algoliasearch>
</modules>
</config>
83 changes: 83 additions & 0 deletions lib/AlgoliaSearch/Analytics.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?php

namespace AlgoliaSearch;

class Analytics
{
/**
* @var \AlgoliaSearch\Client
*/
private $client;

public function __construct(Client $client)
{
$this->client = $client;
}

public function getABTests($params = array())
{
$params += array('offset' => 0, 'limit' => 10);

return $this->request('GET', '/2/abtests', $params);
}

public function getABTest($abTestID)
{
if (!$abTestID) {
throw new AlgoliaException('Cannot retrieve ABTest because the abtestID is invalid.');
}

return $this->request('GET', sprintf('/2/abtests/%s', urlencode($abTestID)));
}

public function addABTest($abTest)
{
return $this->request(
'POST',
'/2/abtests',
array(),
$abTest
);
}

public function stopABTest($abTestID)
{
if (!$abTestID) {
throw new AlgoliaException('Cannot retrieve ABTest because the abtestID is invalid.');
}

return $this->request('POST', sprintf('/2/abtests/%s/stop', urlencode($abTestID)));
}

public function deleteABTest($abTestID)
{
if (!$abTestID) {
throw new AlgoliaException('Cannot retrieve ABTest because the abtestID is invalid.');
}

return $this->request('DELETE', sprintf('/2/abtests/%s', urlencode($abTestID)));
}

public function waitTask($indexName, $taskID, $timeBeforeRetry = 100, $requestHeaders = array())
{
$this->client->waitTask($indexName, $taskID, $timeBeforeRetry, $requestHeaders);
}

protected function request(
$method,
$path,
$params = array(),
$data = array()
) {
return $this->client->request(
$this->client->getContext(),
$method,
$path,
$params,
$data,
array('analytics.algolia.com'),
$this->client->getContext()->connectTimeout,
$this->client->getContext()->readTimeout
);
}
}
Loading

0 comments on commit d8f95e8

Please sign in to comment.