Skip to content

Commit 6084270

Browse files
authored
Implementar robots (#19)
* Implementar robots
1 parent b8aabd8 commit 6084270

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/Google/Index/Listeners/ProductIndexInGoogleListener.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,19 @@ public function handle(ProductPublished $event)
1515
}
1616

1717
$product = ProductRepository::get($event->productId);
18+
$noIndex = $this->getNoIndex($product);
1819

19-
if (! $product) {
20+
if (! $product || $noIndex) {
2021
return;
2122
}
2223

2324
EnqueueUrlService::publish($product['url'], 10);
2425
}
26+
27+
public function getNoIndex($product): bool
28+
{
29+
$robots = $product['meta']['robots'] ?? '';
30+
31+
return str_contains($robots, 'noindex');
32+
}
2533
}

0 commit comments

Comments
 (0)