Skip to content

Commit 0ae953c

Browse files
committed
Merge remote-tracking branch 'origin/v3.2'
# Conflicts: # app/Helpers/StoresAvailable/Amazon.php Took 10 minutes
2 parents 8991b3f + 0bfdd42 commit 0ae953c

36 files changed

+2547
-723
lines changed

.env.test

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
APP_NAME="Discount Bandit"
2+
APP_ENV=local
3+
APP_KEY=
4+
APP_DEBUG=true
5+
6+
APP_LOCALE=en
7+
APP_FALLBACK_LOCALE=en
8+
APP_FAKER_LOCALE=en_US
9+
10+
APP_MAINTENANCE_DRIVER=file
11+
APP_MAINTENANCE_STORE=database
12+
13+
BCRYPT_ROUNDS=12
14+
15+
LOG_CHANNEL=daily
16+
LOG_STACK=single
17+
LOG_DEPRECATIONS_CHANNEL=null
18+
LOG_LEVEL=debug
19+
20+
SESSION_DRIVER=file
21+
SESSION_LIFETIME=120
22+
SESSION_ENCRYPT=false
23+
SESSION_PATH=/
24+
SESSION_DOMAIN=null
25+
26+
BROADCAST_CONNECTION=log
27+
FILESYSTEM_DISK=local
28+
QUEUE_CONNECTION=database
29+
30+
CACHE_STORE=database
31+
CACHE_PREFIX=
32+
33+
MEMCACHED_HOST=127.0.0.1
34+
35+
REDIS_CLIENT=phpredis
36+
REDIS_HOST=127.0.0.1
37+
REDIS_PASSWORD=null
38+
REDIS_PORT=6379
39+
40+
VITE_APP_NAME="${APP_NAME}"
41+
42+
OCTANE_SERVER=frankenphp
43+
OCTANE_HTTPS=false
44+
45+
APP_URL=http://localhost:8000
46+
DB_CONNECTION=sqlite
47+
APP_TIMEZONE=UTC
48+
RSS_FEED=1
49+
NOTIFY_ON_ANY_PRICE_CHANGE=0
50+
TOP_NAVIGATION=0
51+
DISABLE_TOP_BAR=
52+
BREADCRUMBS=1
53+
SPA=1
54+
DISABLE_AUTH=1
55+
THEME_COLOR=Stone
56+

app/Helpers/GeneralHelper.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace App\Helpers;
44

5+
use Illuminate\Support\Str;
6+
57
class GeneralHelper
68
{
79

@@ -11,4 +13,14 @@ public static function get_numbers_only_with_dot($string): array|string|null
1113
}
1214

1315

16+
public static function get_value_from_meta_tag(array $meta_items, string $key , string $attribute): string
17+
{
18+
foreach ($meta_items as $meta)
19+
foreach ($meta->attributes() as $value)
20+
if ($value == $key)
21+
return $meta->attributes()[$attribute]->__toString();
22+
23+
return "";
24+
}
25+
1426
}
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
<?php
2+
3+
namespace App\Helpers\StoresAvailable;
4+
5+
use Error;
6+
use Exception;
7+
use Illuminate\Support\Str;
8+
9+
class Ajio extends StoreTemplate
10+
{
11+
const string MAIN_URL="https://www.store/p/product_id" ;
12+
13+
private $meta_items;
14+
private $product_schema;
15+
16+
public function __construct(int $product_store_id)
17+
{
18+
parent::__construct($product_store_id);
19+
}
20+
21+
//define crawler
22+
public function crawler(): void
23+
{
24+
parent::crawl_url();
25+
}
26+
27+
public function prepare_sections_to_crawl(): void
28+
{
29+
try {
30+
$this->product_schema=$this->get_product_schema(script_type: 'application/ld+json');
31+
}catch (Error | Exception $exception) {
32+
$this->log_error("Crawling Amazon", $exception->getMessage());
33+
}
34+
35+
}
36+
/**
37+
* Get the data from the store
38+
*/
39+
public function get_name(): void
40+
{
41+
try {
42+
$this->name = $this->product_schema['name'];
43+
return;
44+
}
45+
catch (Error | Exception $exception){
46+
$this->log_error("Product Name First Method", $exception->getMessage());
47+
}
48+
}
49+
50+
public function get_image(): void
51+
{
52+
try {
53+
$this->image = $this->product_schema["image"];
54+
}
55+
catch ( Error | Exception $exception) {
56+
$this->log_error("Product Image First Method", $exception->getMessage());
57+
}
58+
}
59+
60+
public function get_price(): void
61+
{
62+
try {
63+
$this->price= (float) $this->product_schema['offers']['price'];
64+
return ;
65+
}
66+
catch ( Error | Exception $exception ) {
67+
$this->log_error("Price First Method",$exception->getMessage());
68+
}
69+
}
70+
71+
public function get_used_price(): void {}
72+
73+
public function get_stock(): void {}
74+
75+
public function get_no_of_rates(): void {}
76+
77+
public function get_rate(): void{}
78+
79+
public function get_seller(): void { $this->seller="Ajio";}
80+
81+
public function get_shipping_price(): void {}
82+
83+
public function get_condition() {}
84+
85+
//toDO
86+
public static function get_variations($url) : array { return []; }
87+
88+
89+
public static function prepare_url( $domain, $product, $store = null): string
90+
{
91+
return Str::replace(
92+
["store", "product_id"],
93+
[$domain , $product],
94+
self::MAIN_URL);
95+
}
96+
97+
//todo didn't encounter it yet
98+
function is_system_detected_as_robot(): bool { return false;}
99+
}

0 commit comments

Comments
 (0)