From e5f90b92d0f3083a8d0bf7a31554b07eaa558107 Mon Sep 17 00:00:00 2001 From: jitendra Date: Thu, 2 Jul 2020 17:00:21 +0530 Subject: [PATCH 1/4] Added support for search with algolia and elasticsearch --- README.md | 1 + composer.json | 3 + composer.lock | 1189 +++++++---------- config/elastic.client.php | 7 + config/scout.php | 91 ++ .../Webkul/Product/src/Models/Product.php | 30 +- .../Webkul/Product/src/Models/ProductFlat.php | 13 + .../src/Repositories/ProductRepository.php | 45 +- 8 files changed, 686 insertions(+), 693 deletions(-) create mode 100644 config/elastic.client.php create mode 100644 config/scout.php diff --git a/README.md b/README.md index 7f7c312b4..956becac1 100755 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ Total Downloads Latest Stable Version License +Backers on Open Collective Backers on Open Collective Sponsors on Open Collective

diff --git a/composer.json b/composer.json index 4a7a583a5..a689929d3 100755 --- a/composer.json +++ b/composer.json @@ -17,7 +17,9 @@ "ext-pdo": "*", "ext-pdo_mysql": "*", "ext-tokenizer": "*", + "algolia/algoliasearch-client-php": "^2.2", "astrotomic/laravel-translatable": "^11.0.0", + "babenkoivan/elastic-scout-driver": "^1.1", "barryvdh/laravel-debugbar": "^3.1", "barryvdh/laravel-dompdf": "0.8.6", "doctrine/dbal": "2.9.2", @@ -30,6 +32,7 @@ "kalnoy/nestedset": "5.0.1", "konekt/concord": "^1.2", "laravel/framework": "^7.0", + "laravel/scout": "^8.0", "laravel/socialite": "^4.4", "laravel/tinker": "^2.0", "laravel/ui": "^2.0", diff --git a/composer.lock b/composer.lock index 0583a4c69..228bcf12f 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,78 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "a64bc9824943e94bc0643161f1bb59d4", + "content-hash": "fdf74de7a5b3178ce60852ca512a6f21", "packages": [ + { + "name": "algolia/algoliasearch-client-php", + "version": "2.7.0", + "source": { + "type": "git", + "url": "https://github.com/algolia/algoliasearch-client-php.git", + "reference": "ce8b35a5aa842ad3e0dc05bbd7aaf5ed82481d71" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/algolia/algoliasearch-client-php/zipball/ce8b35a5aa842ad3e0dc05bbd7aaf5ed82481d71", + "reference": "ce8b35a5aa842ad3e0dc05bbd7aaf5ed82481d71", + "shasum": "" + }, + "require": { + "ext-curl": "*", + "ext-json": "*", + "ext-mbstring": "*", + "php": "^5.3 || ^7.0", + "psr/http-message": "^1.0", + "psr/log": "^1.0", + "psr/simple-cache": "^1.0" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^2.0", + "fzaninotto/faker": "^1.8", + "phpunit/phpunit": "^4.8", + "symfony/yaml": "^2.0 || ^4.0" + }, + "suggest": { + "guzzlehttp/guzzle": "If you prefer to use Guzzle HTTP client instead of the Http Client implementation provided by the package" + }, + "bin": [ + "bin/algolia-doctor" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-2.0": "2.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Algolia\\AlgoliaSearch\\": "src/" + }, + "files": [ + "src/Http/Psr7/functions.php", + "src/functions.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Algolia Team", + "email": "contact@algolia.com" + } + ], + "description": "Algolia Search API Client for PHP", + "keywords": [ + "algolia", + "api", + "client", + "php", + "search" + ], + "time": "2020-06-25T08:47:13+00:00" + }, { "name": "astrotomic/laravel-translatable", "version": "v11.8.1", @@ -69,25 +139,168 @@ "laravel", "translation" ], - "funding": [ + "time": "2020-04-23T08:57:35+00:00" + }, + { + "name": "babenkoivan/elastic-adapter", + "version": "v1.2.0", + "source": { + "type": "git", + "url": "https://github.com/babenkoivan/elastic-adapter.git", + "reference": "d4823c6c9629cc954ec247347e50c1e7a2c8d1b7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/babenkoivan/elastic-adapter/zipball/d4823c6c9629cc954ec247347e50c1e7a2c8d1b7", + "reference": "d4823c6c9629cc954ec247347e50c1e7a2c8d1b7", + "shasum": "" + }, + "require": { + "elasticsearch/elasticsearch": "^7.3", + "php": "^7.2" + }, + "require-dev": { + "phpunit/phpunit": "^8.4" + }, + "type": "library", + "autoload": { + "psr-4": { + "ElasticAdapter\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ { - "url": "https://plant.treeware.earth/Astrotomic/laravel-translatable", - "type": "custom" - }, - { - "url": "https://github.com/Gummibeer", - "type": "github" - }, - { - "url": "https://issuehunt.io/r/astrotomic", - "type": "issuehunt" - }, - { - "url": "https://opencollective.com/astrotomic", - "type": "open_collective" + "name": "Ivan Babenko", + "email": "babenko.i.a@gmail.com" } ], - "time": "2020-04-23T08:57:35+00:00" + "description": "Adapter for official PHP Elasticsearch client", + "keywords": [ + "adapter", + "client", + "elastic", + "elasticsearch", + "php" + ], + "time": "2020-06-20T09:53:44+00:00" + }, + { + "name": "babenkoivan/elastic-client", + "version": "v1.0.1", + "source": { + "type": "git", + "url": "https://github.com/babenkoivan/elastic-client.git", + "reference": "0aa13e8fa1e64f4475b16b6bae1a0ed17b33349c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/babenkoivan/elastic-client/zipball/0aa13e8fa1e64f4475b16b6bae1a0ed17b33349c", + "reference": "0aa13e8fa1e64f4475b16b6bae1a0ed17b33349c", + "shasum": "" + }, + "require": { + "elasticsearch/elasticsearch": "^7.3", + "php": "^7.2" + }, + "require-dev": { + "orchestra/testbench": "^4.3", + "phpunit/phpunit": "^8.4" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "ElasticClient\\ServiceProvider" + ] + } + }, + "autoload": { + "psr-4": { + "ElasticClient\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ivan Babenko", + "email": "babenko.i.a@gmail.com" + } + ], + "description": "The official PHP Elasticsearch client integrated with Laravel", + "keywords": [ + "client", + "elastic", + "elasticsearch", + "laravel", + "php" + ], + "time": "2020-05-12T17:55:14+00:00" + }, + { + "name": "babenkoivan/elastic-scout-driver", + "version": "v1.1.0", + "source": { + "type": "git", + "url": "https://github.com/babenkoivan/elastic-scout-driver.git", + "reference": "d9343e84cdbddbff7cac161c91d1f8b5e9603cf3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/babenkoivan/elastic-scout-driver/zipball/d9343e84cdbddbff7cac161c91d1f8b5e9603cf3", + "reference": "d9343e84cdbddbff7cac161c91d1f8b5e9603cf3", + "shasum": "" + }, + "require": { + "babenkoivan/elastic-adapter": "^1.0", + "babenkoivan/elastic-client": "^1.0", + "php": "^7.2" + }, + "require-dev": { + "babenkoivan/elastic-migrations": "^1.0", + "laravel/scout": "^8.0", + "orchestra/testbench": "^5.2", + "phpunit/phpunit": "^8.5" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "ElasticScoutDriver\\ServiceProvider" + ] + } + }, + "autoload": { + "psr-4": { + "ElasticScoutDriver\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ivan Babenko", + "email": "babenko.i.a@gmail.com" + } + ], + "description": "Elasticsearch driver for Laravel Scout", + "keywords": [ + "driver", + "elastic", + "elasticsearch", + "laravel", + "php", + "scout" + ], + "time": "2020-06-22T14:14:32+00:00" }, { "name": "barryvdh/laravel-debugbar", @@ -155,12 +368,6 @@ "profiler", "webprofiler" ], - "funding": [ - { - "url": "https://github.com/barryvdh", - "type": "github" - } - ], "time": "2020-05-05T10:53:32+00:00" }, { @@ -263,12 +470,6 @@ "brick", "math" ], - "funding": [ - { - "url": "https://tidelift.com/funding/github/packagist/brick/math", - "type": "tidelift" - } - ], "time": "2020-04-15T15:59:35+00:00" }, { @@ -384,20 +585,6 @@ "redis", "xcache" ], - "funding": [ - { - "url": "https://www.doctrine-project.org/sponsorship.html", - "type": "custom" - }, - { - "url": "https://www.patreon.com/phpdoctrine", - "type": "patreon" - }, - { - "url": "https://tidelift.com/funding/github/packagist/doctrine%2Fcache", - "type": "tidelift" - } - ], "time": "2020-05-27T16:24:54+00:00" }, { @@ -633,20 +820,6 @@ "uppercase", "words" ], - "funding": [ - { - "url": "https://www.doctrine-project.org/sponsorship.html", - "type": "custom" - }, - { - "url": "https://www.patreon.com/phpdoctrine", - "type": "patreon" - }, - { - "url": "https://tidelift.com/funding/github/packagist/doctrine%2Finflector", - "type": "tidelift" - } - ], "time": "2020-05-29T15:13:26+00:00" }, { @@ -709,20 +882,6 @@ "parser", "php" ], - "funding": [ - { - "url": "https://www.doctrine-project.org/sponsorship.html", - "type": "custom" - }, - { - "url": "https://www.patreon.com/phpdoctrine", - "type": "patreon" - }, - { - "url": "https://tidelift.com/funding/github/packagist/doctrine%2Flexer", - "type": "tidelift" - } - ], "time": "2020-05-25T17:44:05+00:00" }, { @@ -903,6 +1062,170 @@ ], "time": "2020-02-13T22:36:52+00:00" }, + { + "name": "elasticsearch/elasticsearch", + "version": "v7.8.0", + "source": { + "type": "git", + "url": "https://github.com/elastic/elasticsearch-php.git", + "reference": "5c2d039ae7bdaa1e28f1e66971c5b3314fc36383" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/elastic/elasticsearch-php/zipball/5c2d039ae7bdaa1e28f1e66971c5b3314fc36383", + "reference": "5c2d039ae7bdaa1e28f1e66971c5b3314fc36383", + "shasum": "" + }, + "require": { + "ext-json": ">=1.3.7", + "ezimuel/ringphp": "^1.1.2", + "php": "^7.1", + "psr/log": "~1.0" + }, + "require-dev": { + "cpliakas/git-wrapper": "~2.0", + "doctrine/inflector": "^1.3", + "mockery/mockery": "^1.2", + "phpstan/phpstan": "^0.12", + "phpunit/phpunit": "^7.5", + "squizlabs/php_codesniffer": "^3.4", + "symfony/finder": "~4.0", + "symfony/yaml": "~4.0" + }, + "suggest": { + "ext-curl": "*", + "monolog/monolog": "Allows for client-level logging and tracing" + }, + "type": "library", + "autoload": { + "files": [ + "src/autoload.php" + ], + "psr-4": { + "Elasticsearch\\": "src/Elasticsearch/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "Zachary Tong" + }, + { + "name": "Enrico Zimuel" + } + ], + "description": "PHP Client for Elasticsearch", + "keywords": [ + "client", + "elasticsearch", + "search" + ], + "time": "2020-06-18T19:23:29+00:00" + }, + { + "name": "ezimuel/guzzlestreams", + "version": "3.0.1", + "source": { + "type": "git", + "url": "https://github.com/ezimuel/guzzlestreams.git", + "reference": "abe3791d231167f14eb80d413420d1eab91163a8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ezimuel/guzzlestreams/zipball/abe3791d231167f14eb80d413420d1eab91163a8", + "reference": "abe3791d231167f14eb80d413420d1eab91163a8", + "shasum": "" + }, + "require": { + "php": ">=5.4.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "psr-4": { + "GuzzleHttp\\Stream\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + } + ], + "description": "Fork of guzzle/streams (abandoned) to be used with elasticsearch-php", + "homepage": "http://guzzlephp.org/", + "keywords": [ + "Guzzle", + "stream" + ], + "time": "2020-02-14T23:11:50+00:00" + }, + { + "name": "ezimuel/ringphp", + "version": "1.1.2", + "source": { + "type": "git", + "url": "https://github.com/ezimuel/ringphp.git", + "reference": "0b78f89d8e0bb9e380046c31adfa40347e9f663b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ezimuel/ringphp/zipball/0b78f89d8e0bb9e380046c31adfa40347e9f663b", + "reference": "0b78f89d8e0bb9e380046c31adfa40347e9f663b", + "shasum": "" + }, + "require": { + "ezimuel/guzzlestreams": "^3.0.1", + "php": ">=5.4.0", + "react/promise": "~2.0" + }, + "require-dev": { + "ext-curl": "*", + "phpunit/phpunit": "~4.0" + }, + "suggest": { + "ext-curl": "Guzzle will use specific adapters if cURL is present" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1-dev" + } + }, + "autoload": { + "psr-4": { + "GuzzleHttp\\Ring\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + } + ], + "description": "Fork of guzzle/RingPHP (abandoned) to be used with elasticsearch-php", + "time": "2020-02-14T23:51:21+00:00" + }, { "name": "fideloper/proxy", "version": "4.3.0", @@ -1825,6 +2148,71 @@ ], "time": "2020-06-02T22:34:18+00:00" }, + { + "name": "laravel/scout", + "version": "v8.0.1", + "source": { + "type": "git", + "url": "https://github.com/laravel/scout.git", + "reference": "85e018b752088057881f780e05a85c8657ff8e95" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/laravel/scout/zipball/85e018b752088057881f780e05a85c8657ff8e95", + "reference": "85e018b752088057881f780e05a85c8657ff8e95", + "shasum": "" + }, + "require": { + "illuminate/bus": "^6.0|^7.0", + "illuminate/contracts": "^6.0|^7.0", + "illuminate/database": "^6.0|^7.0", + "illuminate/pagination": "^6.0|^7.0", + "illuminate/queue": "^6.0|^7.0", + "illuminate/support": "^6.0|^7.0", + "php": "^7.2" + }, + "require-dev": { + "algolia/algoliasearch-client-php": "^2.2", + "mockery/mockery": "^1.0", + "phpunit/phpunit": "^8.0" + }, + "suggest": { + "algolia/algoliasearch-client-php": "Required to use the Algolia engine (^2.2)." + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "8.x-dev" + }, + "laravel": { + "providers": [ + "Laravel\\Scout\\ScoutServiceProvider" + ] + } + }, + "autoload": { + "psr-4": { + "Laravel\\Scout\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Taylor Otwell", + "email": "taylor@laravel.com" + } + ], + "description": "Laravel Scout provides a driver based solution to searching your Eloquent models.", + "keywords": [ + "algolia", + "laravel", + "search" + ], + "time": "2020-04-21T19:33:18+00:00" + }, { "name": "laravel/socialite", "version": "v4.4.1", @@ -2062,16 +2450,6 @@ "JWS", "jwt" ], - "funding": [ - { - "url": "https://github.com/lcobucci", - "type": "github" - }, - { - "url": "https://www.patreon.com/lcobucci", - "type": "patreon" - } - ], "time": "2020-05-22T08:21:12+00:00" }, { @@ -2146,32 +2524,6 @@ "md", "parser" ], - "funding": [ - { - "url": "https://enjoy.gitstore.app/repositories/thephpleague/commonmark", - "type": "custom" - }, - { - "url": "https://www.colinodell.com/sponsor", - "type": "custom" - }, - { - "url": "https://www.paypal.me/colinpodell/10.00", - "type": "custom" - }, - { - "url": "https://github.com/colinodell", - "type": "github" - }, - { - "url": "https://www.patreon.com/colinodell", - "type": "patreon" - }, - { - "url": "https://tidelift.com/funding/github/packagist/league/commonmark", - "type": "tidelift" - } - ], "time": "2020-05-04T22:15:21+00:00" }, { @@ -2256,12 +2608,6 @@ "sftp", "storage" ], - "funding": [ - { - "url": "https://offset.earth/frankdejonge", - "type": "other" - } - ], "time": "2020-05-18T15:13:39+00:00" }, { @@ -2392,16 +2738,6 @@ "php", "phpspreadsheet" ], - "funding": [ - { - "url": "https://laravel-excel.com/commercial-support", - "type": "custom" - }, - { - "url": "https://github.com/patrickbrouwers", - "type": "github" - } - ], "time": "2020-02-28T15:47:45+00:00" }, { @@ -2463,12 +2799,6 @@ "stream", "zip" ], - "funding": [ - { - "url": "https://opencollective.com/zipstream", - "type": "open_collective" - } - ], "time": "2020-05-30T13:11:16+00:00" }, { @@ -2775,16 +3105,6 @@ "logging", "psr-3" ], - "funding": [ - { - "url": "https://github.com/Seldaek", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/monolog/monolog", - "type": "tidelift" - } - ], "time": "2020-05-22T08:12:19+00:00" }, { @@ -2967,16 +3287,6 @@ "datetime", "time" ], - "funding": [ - { - "url": "https://opencollective.com/Carbon", - "type": "open_collective" - }, - { - "url": "https://tidelift.com/funding/github/packagist/nesbot/carbon", - "type": "tidelift" - } - ], "time": "2020-05-24T18:27:52+00:00" }, { @@ -3316,16 +3626,6 @@ "php", "type" ], - "funding": [ - { - "url": "https://github.com/GrahamCampbell", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/phpoption/phpoption", - "type": "tidelift" - } - ], "time": "2020-06-07T10:40:07+00:00" }, { @@ -3929,13 +4229,53 @@ "identifier", "uuid" ], - "funding": [ + "time": "2020-03-29T20:13:32+00:00" + }, + { + "name": "react/promise", + "version": "v2.8.0", + "source": { + "type": "git", + "url": "https://github.com/reactphp/promise.git", + "reference": "f3cff96a19736714524ca0dd1d4130de73dbbbc4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/reactphp/promise/zipball/f3cff96a19736714524ca0dd1d4130de73dbbbc4", + "reference": "f3cff96a19736714524ca0dd1d4130de73dbbbc4", + "shasum": "" + }, + "require": { + "php": ">=5.4.0" + }, + "require-dev": { + "phpunit/phpunit": "^7.0 || ^6.5 || ^5.7 || ^4.8.36" + }, + "type": "library", + "autoload": { + "psr-4": { + "React\\Promise\\": "src/" + }, + "files": [ + "src/functions_include.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ { - "url": "https://github.com/ramsey", - "type": "github" + "name": "Jan Sorgalla", + "email": "jsorgalla@gmail.com" } ], - "time": "2020-03-29T20:13:32+00:00" + "description": "A lightweight implementation of CommonJS Promises/A for PHP", + "keywords": [ + "promise", + "promises" + ], + "time": "2020-05-12T15:16:56+00:00" }, { "name": "sabberworm/php-css-parser", @@ -4121,20 +4461,6 @@ ], "description": "Symfony Console Component", "homepage": "https://symfony.com", - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], "time": "2020-05-30T20:35:19+00:00" }, { @@ -4188,20 +4514,6 @@ ], "description": "Symfony CssSelector Component", "homepage": "https://symfony.com", - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], "time": "2020-05-20T17:43:50+00:00" }, { @@ -4259,20 +4571,6 @@ ], "description": "Symfony Debug Component", "homepage": "https://symfony.com", - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], "time": "2020-05-24T08:33:35+00:00" }, { @@ -4319,20 +4617,6 @@ ], "description": "A generic function and convention to trigger deprecation notices", "homepage": "https://symfony.com", - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], "time": "2020-05-27T08:34:37+00:00" }, { @@ -4390,20 +4674,6 @@ ], "description": "Symfony ErrorHandler Component", "homepage": "https://symfony.com", - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], "time": "2020-05-30T20:35:19+00:00" }, { @@ -4476,20 +4746,6 @@ ], "description": "Symfony EventDispatcher Component", "homepage": "https://symfony.com", - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], "time": "2020-05-20T17:43:50+00:00" }, { @@ -4548,20 +4804,6 @@ "interoperability", "standards" ], - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], "time": "2020-05-20T17:43:50+00:00" }, { @@ -4611,20 +4853,6 @@ ], "description": "Symfony Finder Component", "homepage": "https://symfony.com", - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], "time": "2020-05-20T17:43:50+00:00" }, { @@ -4686,20 +4914,6 @@ ], "description": "Symfony HttpFoundation Component", "homepage": "https://symfony.com", - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], "time": "2020-05-24T12:18:07+00:00" }, { @@ -4799,20 +5013,6 @@ ], "description": "Symfony HttpKernel Component", "homepage": "https://symfony.com", - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], "time": "2020-05-31T06:14:18+00:00" }, { @@ -4876,20 +5076,6 @@ "mime", "mime-type" ], - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], "time": "2020-05-25T12:33:44+00:00" }, { @@ -4948,20 +5134,6 @@ "polyfill", "portable" ], - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], "time": "2020-05-12T16:14:59+00:00" }, { @@ -5021,20 +5193,6 @@ "portable", "shim" ], - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], "time": "2020-05-12T16:47:27+00:00" }, { @@ -5095,20 +5253,6 @@ "portable", "shim" ], - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], "time": "2020-05-12T16:47:27+00:00" }, { @@ -5171,20 +5315,6 @@ "portable", "shim" ], - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], "time": "2020-05-12T16:47:27+00:00" }, { @@ -5248,20 +5378,6 @@ "portable", "shim" ], - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], "time": "2020-05-12T16:14:59+00:00" }, { @@ -5321,20 +5437,6 @@ "portable", "shim" ], - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], "time": "2020-05-12T16:47:27+00:00" }, { @@ -5391,20 +5493,6 @@ "portable", "shim" ], - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], "time": "2020-05-12T16:47:27+00:00" }, { @@ -5460,20 +5548,6 @@ "portable", "shim" ], - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], "time": "2020-05-12T16:47:27+00:00" }, { @@ -5532,20 +5606,6 @@ "portable", "shim" ], - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], "time": "2020-05-12T16:47:27+00:00" }, { @@ -5608,20 +5668,6 @@ "portable", "shim" ], - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], "time": "2020-05-12T16:47:27+00:00" }, { @@ -5674,20 +5720,6 @@ "polyfill", "shim" ], - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], "time": "2020-05-12T16:14:59+00:00" }, { @@ -5738,20 +5770,6 @@ ], "description": "Symfony Process Component", "homepage": "https://symfony.com", - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], "time": "2020-05-30T20:35:19+00:00" }, { @@ -5830,20 +5848,6 @@ "uri", "url" ], - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], "time": "2020-05-30T20:35:19+00:00" }, { @@ -5902,20 +5906,6 @@ "interoperability", "standards" ], - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], "time": "2020-05-20T17:43:50+00:00" }, { @@ -5987,20 +5977,6 @@ "utf-8", "utf8" ], - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], "time": "2020-05-20T17:43:50+00:00" }, { @@ -6079,20 +6055,6 @@ ], "description": "Symfony Translation Component", "homepage": "https://symfony.com", - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], "time": "2020-05-30T20:35:19+00:00" }, { @@ -6150,20 +6112,6 @@ "interoperability", "standards" ], - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], "time": "2020-05-20T17:43:50+00:00" }, { @@ -6240,20 +6188,6 @@ "debug", "dump" ], - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], "time": "2020-05-30T20:35:19+00:00" }, { @@ -6377,12 +6311,6 @@ "jwt", "laravel" ], - "funding": [ - { - "url": "https://www.patreon.com/seantymon", - "type": "patreon" - } - ], "time": "2020-03-04T11:21:28+00:00" }, { @@ -6447,16 +6375,6 @@ "env", "environment" ], - "funding": [ - { - "url": "https://github.com/GrahamCampbell", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/vlucas/phpdotenv", - "type": "tidelift" - } - ], "time": "2020-06-07T18:25:35+00:00" }, { @@ -6505,24 +6423,6 @@ "clean", "php" ], - "funding": [ - { - "url": "https://www.paypal.me/moelleken", - "type": "custom" - }, - { - "url": "https://github.com/voku", - "type": "github" - }, - { - "url": "https://www.patreon.com/voku", - "type": "patreon" - }, - { - "url": "https://tidelift.com/funding/github/packagist/voku/portable-ascii", - "type": "tidelift" - } - ], "time": "2020-05-26T06:40:44+00:00" } ], @@ -7105,20 +7005,6 @@ "constructor", "instantiate" ], - "funding": [ - { - "url": "https://www.doctrine-project.org/sponsorship.html", - "type": "custom" - }, - { - "url": "https://www.patreon.com/phpdoctrine", - "type": "patreon" - }, - { - "url": "https://tidelift.com/funding/github/packagist/doctrine%2Finstantiator", - "type": "tidelift" - } - ], "time": "2020-05-29T17:27:14+00:00" }, { @@ -7458,20 +7344,6 @@ "php", "symfony" ], - "funding": [ - { - "url": "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=66BYDWAT92N6L", - "type": "custom" - }, - { - "url": "https://github.com/nunomaduro", - "type": "github" - }, - { - "url": "https://www.patreon.com/nunomaduro", - "type": "patreon" - } - ], "time": "2020-04-04T19:56:08+00:00" }, { @@ -8185,16 +8057,6 @@ "testing", "xunit" ], - "funding": [ - { - "url": "https://phpunit.de/donate.html", - "type": "custom" - }, - { - "url": "https://github.com/sebastianbergmann", - "type": "github" - } - ], "time": "2020-05-22T13:51:52+00:00" }, { @@ -8869,20 +8731,6 @@ ], "description": "Symfony BrowserKit Component", "homepage": "https://symfony.com", - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], "time": "2020-05-23T13:13:03+00:00" }, { @@ -8945,20 +8793,6 @@ ], "description": "Symfony DomCrawler Component", "homepage": "https://symfony.com", - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], "time": "2020-05-23T13:08:13+00:00" }, { @@ -9022,20 +8856,6 @@ ], "description": "Symfony Yaml Component", "homepage": "https://symfony.com", - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], "time": "2020-05-20T17:43:50+00:00" }, { @@ -9142,6 +8962,5 @@ "ext-pdo_mysql": "*", "ext-tokenizer": "*" }, - "platform-dev": [], - "plugin-api-version": "1.1.0" + "platform-dev": [] } diff --git a/config/elastic.client.php b/config/elastic.client.php new file mode 100644 index 000000000..13fb60386 --- /dev/null +++ b/config/elastic.client.php @@ -0,0 +1,7 @@ + [ + env('ELASTIC_HOST', 'localhost:9200'), + ] +]; diff --git a/config/scout.php b/config/scout.php new file mode 100644 index 000000000..96f740d08 --- /dev/null +++ b/config/scout.php @@ -0,0 +1,91 @@ + env('SCOUT_DRIVER', 'algolia'), + + /* + |-------------------------------------------------------------------------- + | Index Prefix + |-------------------------------------------------------------------------- + | + | Here you may specify a prefix that will be applied to all search index + | names used by Scout. This prefix may be useful if you have multiple + | "tenants" or applications sharing the same search infrastructure. + | + */ + + 'prefix' => env('SCOUT_PREFIX', ''), + + /* + |-------------------------------------------------------------------------- + | Queue Data Syncing + |-------------------------------------------------------------------------- + | + | This option allows you to control if the operations that sync your data + | with your search engines are queued. When this is set to "true" then + | all automatic data syncing will get queued for better performance. + | + */ + + 'queue' => env('SCOUT_QUEUE', false), + + /* + |-------------------------------------------------------------------------- + | Chunk Sizes + |-------------------------------------------------------------------------- + | + | These options allow you to control the maximum chunk size when you are + | mass importing data into the search engine. This allows you to fine + | tune each of these chunk sizes based on the power of the servers. + | + */ + + 'chunk' => [ + 'searchable' => 500, + 'unsearchable' => 500, + ], + + /* + |-------------------------------------------------------------------------- + | Soft Deletes + |-------------------------------------------------------------------------- + | + | This option allows to control whether to keep soft deleted records in + | the search indexes. Maintaining soft deleted records can be useful + | if your application still needs to search for the records later. + | + */ + + 'soft_delete' => false, + + /* + |-------------------------------------------------------------------------- + | Algolia Configuration + |-------------------------------------------------------------------------- + | + | Here you may configure your Algolia settings. Algolia is a cloud hosted + | search engine which works great with Scout out of the box. Just plug + | in your application ID and admin API key to get started searching. + | + */ + + 'algolia' => [ + 'id' => env('ALGOLIA_APP_ID', ''), + 'secret' => env('ALGOLIA_SECRET', ''), + ], + +]; diff --git a/packages/Webkul/Product/src/Models/Product.php b/packages/Webkul/Product/src/Models/Product.php index 4ba4b12c6..86acea5a1 100755 --- a/packages/Webkul/Product/src/Models/Product.php +++ b/packages/Webkul/Product/src/Models/Product.php @@ -20,9 +20,27 @@ class Product extends Model implements ProductContract protected $typeInstance; - // protected $with = ['attribute_family', 'inventories']; + /** + * The "booted" method of the model. + * + * @return void + */ + protected static function booted() + { + parent::boot(); - // protected $table = 'products'; + static::deleting(function ($product) { + foreach ($product->product_flats as $productFlat) { + $productFlat->unsearchable(); + } + + foreach ($product->variants as $variant) { + foreach ($variant->product_flats as $productFlat) { + $productFlat->unsearchable(); + } + } + }); + } /** * Get the product attribute family that owns the product. @@ -40,6 +58,14 @@ class Product extends Model implements ProductContract return $this->hasMany(ProductAttributeValueProxy::modelClass()); } + /** + * Get the product variants that owns the product. + */ + public function product_flats() + { + return $this->hasMany(ProductFlatProxy::modelClass(), 'product_id'); + } + /** * Get the product variants that owns the product. */ diff --git a/packages/Webkul/Product/src/Models/ProductFlat.php b/packages/Webkul/Product/src/Models/ProductFlat.php index f84a856da..1e0517755 100644 --- a/packages/Webkul/Product/src/Models/ProductFlat.php +++ b/packages/Webkul/Product/src/Models/ProductFlat.php @@ -3,10 +3,13 @@ namespace Webkul\Product\Models; use Illuminate\Database\Eloquent\Model; +use Laravel\Scout\Searchable; use Webkul\Product\Contracts\ProductFlat as ProductFlatContract; class ProductFlat extends Model implements ProductFlatContract { + use Searchable; + protected $table = 'product_flat'; protected $guarded = [ @@ -17,6 +20,16 @@ class ProductFlat extends Model implements ProductFlatContract public $timestamps = false; + /** + * Get the index name for the model. + * + * @return string + */ + public function searchableAs() + { + return 'products_index'; + } + /** * Retrieve type instance * diff --git a/packages/Webkul/Product/src/Repositories/ProductRepository.php b/packages/Webkul/Product/src/Repositories/ProductRepository.php index f1cf3b6f9..9d0b0e8a4 100755 --- a/packages/Webkul/Product/src/Repositories/ProductRepository.php +++ b/packages/Webkul/Product/src/Repositories/ProductRepository.php @@ -344,12 +344,44 @@ class ProductRepository extends Repository */ public function searchProductByAttribute($term) { - $results = app(ProductFlatRepository::class)->scopeQuery(function($query) use($term) { - $channel = request()->get('channel') ?: (core()->getCurrentChannelCode() ?: core()->getDefaultChannelCode()); + $channel = request()->get('channel') ?: (core()->getCurrentChannelCode() ?: core()->getDefaultChannelCode()); - $locale = request()->get('locale') ?: app()->getLocale(); + $locale = request()->get('locale') ?: app()->getLocale(); - return $query->distinct() + if (config('scout.driver') == 'algolia') { + $results = app(ProductFlatRepository::class)->getModel()::search('query', function ($searchDriver, string $query, array $options) use($term, $channel, $locale) { + $queries = explode('_', $term); + + $options['similarQuery'] = array_map('trim', $queries); + + $searchDriver->setSettings([ + 'attributesForFaceting' => [ + "searchable(locale)", + "searchable(channel)" + ] + ]); + + $options['facetFilters'] = ['locale:' . $locale, 'channel:' . $channel]; + + return $searchDriver->search($query, $options); + }) + ->where('status', 1) + ->where('visible_individually', 1) + ->orderBy('product_id', 'desc') + ->paginate(16); + } else if(config('scout.driver') == 'elastic') { + $queries = explode('_', $term); + + $results = app(ProductFlatRepository::class)->getModel()::search(implode(' OR ', $queries)) + ->where('status', 1) + ->where('visible_individually', 1) + ->where('channel', $channel) + ->where('locale', $locale) + ->orderBy('product_id', 'desc') + ->paginate(16); + } else { + $results = app(ProductFlatRepository::class)->scopeQuery(function($query) use($term, $channel, $locale) { + return $query->distinct() ->addSelect('product_flat.*') ->where('product_flat.status', 1) ->where('product_flat.visible_individually', 1) @@ -361,11 +393,12 @@ class ProductRepository extends Repository foreach (array_map('trim', $queries) as $value) { $subQuery->orWhere('product_flat.name', 'like', '%' . urldecode($value) . '%') - ->orWhere('product_flat.short_description', 'like', '%' . urldecode($value) . '%'); + ->orWhere('product_flat.short_description', 'like', '%' . urldecode($value) . '%'); } }) ->orderBy('product_id', 'desc'); - })->paginate(16); + })->paginate(16); + } return $results; } From 966524e9bc86fb3c17cdc8a108aeecf4fd0a3fcc Mon Sep 17 00:00:00 2001 From: jitendra Date: Thu, 2 Jul 2020 17:03:27 +0530 Subject: [PATCH 2/4] Added workflow actions link to ci badge in readme file --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 956becac1..da77f89fe 100755 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Total Downloads Latest Stable Version License -Backers on Open Collective +Backers on Open Collective Backers on Open Collective Sponsors on Open Collective

From 75a40efccd0d16c46ee73d0814be46290885f9d5 Mon Sep 17 00:00:00 2001 From: jitendra Date: Thu, 2 Jul 2020 17:09:51 +0530 Subject: [PATCH 3/4] Remove defaul scout driver from scout config --- config/scout.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/scout.php b/config/scout.php index 96f740d08..a0f869a5b 100644 --- a/config/scout.php +++ b/config/scout.php @@ -15,7 +15,7 @@ return [ | */ - 'driver' => env('SCOUT_DRIVER', 'algolia'), + 'driver' => env('SCOUT_DRIVER', ''), /* |-------------------------------------------------------------------------- From 03b6f679bf02b4b122db7393e299d4722a9ab909 Mon Sep 17 00:00:00 2001 From: jitendra Date: Thu, 2 Jul 2020 17:15:27 +0530 Subject: [PATCH 4/4] Remove defaul scout driver from scout config --- config/scout.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/scout.php b/config/scout.php index a0f869a5b..b2f0f4d22 100644 --- a/config/scout.php +++ b/config/scout.php @@ -15,7 +15,7 @@ return [ | */ - 'driver' => env('SCOUT_DRIVER', ''), + 'driver' => env('SCOUT_DRIVER', null), /* |-------------------------------------------------------------------------- @@ -41,7 +41,7 @@ return [ | */ - 'queue' => env('SCOUT_QUEUE', false), + 'queue' => env('SCOUT_QUEUE', true), /* |--------------------------------------------------------------------------