Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

google search: mejorar la gestión de URLs no encontradas en el serv… #16

Merged
merged 1 commit into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions src/Google/Index/Listeners/ProductUnIndexInGoogleListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,12 @@ public function handle(ProductUnpublished $event)
return;
}

// TODO no lo encontrará quizas sea mejor idea conectar a la DB
// $product = ProductRepository::get($event->productId);
$url = $event->attributes['url'] ?? null;

// if (! $product || ! isset($product['url'])) {
// return;
// }
if (! $url) {
return;
}

// EnqueueUrlService::unpublish($product['url']);
EnqueueUrlService::unpublish($url);
}
}
10 changes: 10 additions & 0 deletions src/Google/Index/Services/IndexUrlService.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use DescomMarket\Feeds\Google\GoogleServiceBuilder;
use Google\Service\Indexing\UrlNotification;
use Illuminate\Support\Facades\Http;

class IndexUrlService
{
Expand All @@ -15,10 +16,19 @@ public function run(string $url): void
return;
}

if ($this->isNotFound($url)) {
return;
}

$urlNotification = new UrlNotification();
$urlNotification->setType('URL_UPDATED');
$urlNotification->setUrl($url);

GoogleServiceBuilder::googleIndex()->urlNotifications->publish($urlNotification);
}

private function isNotFound(string $url): bool
{
return Http::get($url)->notFound();
}
}
Loading