Source of file Products.php
Size: 1,896 Bytes - Last Modified: 2021-12-24T05:18:55+00:00
/var/www/docs.ssmods.com/process/src/src/App/Products.php
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 | <?php namespace IQnection\BigCommerceApp\App; use SilverStripe\Core\Extension; use SilverStripe\Forms; use SilverStripe\ORM\ValidationException; use SilverStripe\ORM\PaginatedList; use IQnection\BigCommerceApp\Model\Product; use SilverStripe\View\Requirements; use SilverStripe\View\ArrayData; use IQnection\BigCommerceApp\Cron\BackgroundJob; class Products extends Main { private static $managed_class = Product::class; private static $url_segment = '_bc/products'; private static $allowed_actions = [ 'edit', 'resync', 'search', 'relation' ]; private static $nav_links = [ 'Products' => [ 'path' => '', 'icon' => 'th-large' ] ]; private static $theme_packages = [ 'forms', 'datatables' ]; public function index() { Requirements::customScript( <<<JS (function($){ "use strict"; $(document).ready(function(){ $("#product-list").dataTable({ "processing": true, "serverSide": true, "ordering": false, "pageLength": 100, "deferRender": true, "searchDelay": 750, "columns": [ { "data": "Thumbnail", "searchable": false }, // { "data": "ID", "searchable": false }, // { "data": "BigID" }, { "data": "Title" }, { "data": "SKU" }, // { "data": "Created", "searchable": false }, { "data": "Actions", "className": "text-right text-nowrap", "orderable": false, "searchable": false, "createdCell": function(td, cellData, rowData, row, col) { return $(td).html('<a href="{$this->Link('edit')}'+(rowData.ID)+'" class="btn btn-primary btn-sm">Edit</a>'); } } ], "ajax": "{$this->Link('search_api')}" }); }); }(jQuery)); JS ); return $this->searchProducts(null, 'products'); } public function SyncStatus() { $job = BackgroundJob::get()->Filter(['Name' => 'sync_products'])->Exclude('Status',BackgroundJob::STATUS_FAILED)->Sort('CompleteDate','DESC')->First(); return $job; } } |