Skip to content

Commit

Permalink
Use the selected site in the control panel (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
BobWez98 authored Jul 9, 2024
1 parent f4b443e commit fc5b4d8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/Models/Brand.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;
use Statamic\Facades\Site;
use Statamic\Statamic;

class Brand extends Model
{
Expand Down Expand Up @@ -36,7 +37,7 @@ protected static function booting()
})
->leftJoinSub($renamedStore, 'store_value', function ($join) {
$join->on('store_value.sub_option_id', '=', 'eav_attribute_option.option_id')
->where('store_value.store_id', Site::current()->attributes['magento_store_id']);
->where('store_value.store_id', (Statamic::isCpRoute() ? Site::selected()->attributes['magento_store_id'] : Site::current()->attributes['magento_store_id']));
})
->where('attribute_id', config('rapidez.statamic.runway.brand_attribute_id'));
});
Expand Down
3 changes: 2 additions & 1 deletion src/Models/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use DoubleThreeDigital\Runway\Traits\HasRunwayResource;
use Illuminate\Database\Eloquent\Model;
use Statamic\Facades\Site;
use Statamic\Statamic;

class Category extends Model
{
Expand All @@ -14,6 +15,6 @@ class Category extends Model

public function getTable()
{
return 'catalog_category_flat_store_'.Site::current()->attributes['magento_store_id'];
return 'catalog_category_flat_store_'.(Statamic::isCpRoute() ? Site::selected()->attributes['magento_store_id'] : Site::current()->attributes['magento_store_id']);
}
}
3 changes: 2 additions & 1 deletion src/Models/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Statamic\Facades\Site;
use Statamic\Statamic;

class Product extends Model
{
Expand All @@ -23,6 +24,6 @@ protected static function booting()

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

0 comments on commit fc5b4d8

Please sign in to comment.