Skip to content
Draft
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
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
"php": "^8.1",
"justbetter/statamic-glide-directive": "^3.0",
"rapidez/blade-directives": "^1.0",
"rapidez/core": "^4.0",
"rapidez/sitemap": "^4.0",
"rapidez/core": "^5.0",
"rapidez/sitemap": "^5.0",
"spatie/once": "*",
"statamic-rad-pack/runway": "^8.3",
"statamic/cms": "^5.55",
Expand Down
6 changes: 4 additions & 2 deletions resources/js/components/FormConditions.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<script>
import '/public/vendor/statamic/frontend/js/helpers.js'
Vue.prototype.Statamic = window.Statamic
if (window?.app?.config?.globalProperties) {
window.app.config.globalProperties.Statamic = window.Statamic
}

export default {
props: {
Expand All @@ -15,7 +17,7 @@ export default {
};
},
render() {
return this.$scopedSlots.default({
return this?.$slots?.default?.({
formData: this.formData
});
},
Expand Down
8 changes: 5 additions & 3 deletions resources/js/components/FormSubmission.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<script>
import '/public/vendor/statamic/frontend/js/helpers.js'
Vue.prototype.Statamic = window.Statamic
if (window?.app?.config?.globalProperties) {
window.app.config.globalProperties.Statamic = window.Statamic
}

export default {
props: {
Expand All @@ -15,14 +17,14 @@ export default {
};
},
render() {
return this.$scopedSlots.default({
return this?.$slots?.default?.({
submit: this.submit,
success: this.success,
error: this.error
});
},
mounted() {
let token = this.$root.csrfToken
let token = window?.app?.config?.globalProperties?.csrfToken
let csrfField = this.$el.querySelector('input[value="STATAMIC_CSRF_TOKEN"]')

if (csrfField && token && token !== 'STATAMIC_CSRF_TOKEN') {
Expand Down
14 changes: 11 additions & 3 deletions resources/js/package.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
import 'Vendor/rapidez/core/resources/js/vue'

Vue.component('form-conditions', () => import('./components/FormConditions.vue'));
Vue.component('form-submission', () => import('./components/FormSubmission.vue'));
document.addEventListener('vue:loaded', (e) => {
const vue = e.detail.vue
vue.component('form-conditions', () => import('./components/FormConditions.vue'))
vue.component('form-submission', () => import('./components/FormSubmission.vue'))
})

document.addEventListener('statamic:nocache.replaced', (e) => {
window.app.csrfToken = e?.detail?.csrf ?? window.app.csrfToken
const token = e?.detail?.csrf
if (token) {
if (window?.app?.config?.globalProperties) {
window.app.config.globalProperties.csrfToken = token
}
}
})
10 changes: 5 additions & 5 deletions src/Commands/InvalidateCacheCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,18 +75,18 @@ public function handle(Cacher $cacher, Writer $writer): void

protected function addProductsUrls(): self
{
$products = config('rapidez.models.product')::withoutGlobalScopes()
$products = config('rapidez.models.product')::query()
->where('updated_at', '>=', $this->latestCheck)
->orWhereIn('entity_id', $this->getUpdatedStockProducts())
->with(['parent:entity_id' => ['rewrites']])
->with(['parents:entity_id' => ['rewrites']])
->with('rewrites')
->get('entity_id');
->get();

foreach ($products as $product) {
$this->addUrls($this->getUrlsFromRewrites($product->rewrites));

if ($product->parent) {
$this->addUrls($this->getUrlsFromRewrites($product->parent->rewrites));
foreach ($product->parents as $parent) {
$this->addUrls($this->getUrlsFromRewrites($parent->rewrites));
}
}

Expand Down
18 changes: 3 additions & 15 deletions src/Models/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,23 @@

use Illuminate\Database\Eloquent\Attributes\ObservedBy;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Rapidez\Statamic\Collections\Products;
use Rapidez\Core\Models\Product as CoreProduct;
use Rapidez\Statamic\Models\Traits\HasContentEntry;
use Rapidez\Statamic\Observers\RunwayObserver;
use StatamicRadPack\Runway\Traits\HasRunwayResource;
use Statamic\Facades\Site;
use Statamic\Statamic;
use Rapidez\Statamic\Facades\RapidezStatamic;

#[ObservedBy([RunwayObserver::class])]
class Product extends Model
class Product extends CoreProduct
{
use HasRunwayResource, HasContentEntry;

protected $primaryKey = 'sku';
protected $keyType = 'string';

public string $linkField = 'linked_product';
public string $collection = 'products';

protected static function booting()
{
static::addGlobalScope(function (Builder $builder) {
$builder->whereIn('visibility', config('rapidez.statamic.runway.product_visibility'));
$builder->whereInAttribute('visibility', config('rapidez.statamic.runway.product_visibility'));
});
}

public function getTable()
{
return 'catalog_product_flat_' . RapidezStatamic::getCurrentStoreId();
}
}