Product.php 705 B

12345678910111213141516171819202122232425262728
  1. <?php
  2. namespace Webkul\Sitemap\Models;
  3. use Illuminate\Support\Carbon;
  4. use Spatie\Sitemap\Contracts\Sitemapable;
  5. use Spatie\Sitemap\Tags\Url;
  6. use Webkul\Product\Models\Product as BaseProduct;
  7. class Product extends BaseProduct implements Sitemapable
  8. {
  9. /**
  10. * To get the sitemap tag for the product.
  11. */
  12. public function toSitemapTag(): Url|string|array
  13. {
  14. if (
  15. ! $this->url_key
  16. || ! $this->status
  17. || ! $this->visible_individually
  18. ) {
  19. return [];
  20. }
  21. return Url::create(route('shop.product_or_category.index', $this->url_key))
  22. ->setLastModificationDate(Carbon::create($this->updated_at));
  23. }
  24. }