Skip to content

Commit

Permalink
Merge branch 'master' of github.com:rapidez/statamic into feature/sit…
Browse files Browse the repository at this point in the history
…e-config
  • Loading branch information
Kevin Meijer committed Nov 5, 2024
2 parents aff4690 + 6b879ae commit 6cd5fdc
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 7 deletions.
12 changes: 11 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
# Changelog

[Unreleased changes](https://github.com/rapidez/statamic/compare/4.2.0...4.2.0)
[Unreleased changes](https://github.com/rapidez/statamic/compare/4.3.0...4.3.0)
## [4.3.0](https://github.com/rapidez/statamic/releases/tag/4.3.0) - 2024-10-30

### Changed

- Removed justbetter/statamic-eloquent-driver-globalset-migration-generator (#83)

### Fixed

- Performance optimizations (#77)

## [4.2.0](https://github.com/rapidez/statamic/releases/tag/4.2.0) - 2024-09-26

### Changed
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
"prefer-stable": true,
"require": {
"php": "^8.1|^8.2",
"justbetter/statamic-eloquent-driver-globalset-migration-generator": "^0.1.0",
"rapidez/blade-directives": "^0.6",
"justbetter/statamic-glide-directive": "^2.1",
"spatie/once": "*",
"statamic-rad-pack/runway": "^7.6",
"statamic/cms": "^5.29",
"statamic/eloquent-driver": "^4.9",
Expand Down
10 changes: 7 additions & 3 deletions src/Extend/SitesLinkedToMagentoStores.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Rapidez\Statamic\Extend;

use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Cache;
use Rapidez\Core\Facades\Rapidez;
use Statamic\Sites\Sites;
Expand All @@ -10,17 +11,20 @@ class SitesLinkedToMagentoStores extends Sites
{
public function findByUrl($url)
{
if ($site = $this->findByMageRunCode(request()->server('MAGE_RUN_CODE'))) {
if ($site = once(fn() => $this->findByMageRunCode(request()->server('MAGE_RUN_CODE')))) {
return $site;
}

return parent::findByUrl($url);
return once(fn() => parent::findByUrl($url));
}


public function findByMageRunCode($code)
{
return collect($this->sites)->get($code);
if (!$code || !($this->sites instanceof Collection)) {
return null;
}
return $this->sites->get($code);
}

protected function getSavedSites()
Expand Down
5 changes: 4 additions & 1 deletion src/Models/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ class Category extends Model

public function getTable()
{
return 'catalog_category_flat_store_'.(Statamic::isCpRoute() ? (Site::selected()->attributes['magento_store_id'] ?? '1') : (Site::current()->attributes['magento_store_id'] ?? '1'));
return 'catalog_category_flat_store_'.once(fn() => (Statamic::isCpRoute()
? (Site::selected()->attributes['magento_store_id'] ?? '1')
: (Site::current()->attributes['magento_store_id'] ?? '1')
));
}
}
5 changes: 4 additions & 1 deletion src/Models/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ protected static function booting()

public function getTable()
{
return 'catalog_product_flat_' . (Statamic::isCpRoute() ? (Site::selected()->attributes['magento_store_id'] ?? '1') : Site::current()->attributes['magento_store_id'] ?? '1');
return 'catalog_product_flat_' . once(fn() => (Statamic::isCpRoute()
? (Site::selected()->attributes['magento_store_id'] ?? '1')
: (Site::current()->attributes['magento_store_id'] ?? '1')
));
}
}

0 comments on commit 6cd5fdc

Please sign in to comment.