Source of file Categories.php
Size: 1,185 Bytes - Last Modified: 2021-12-24T05:18:55+00:00
/var/www/docs.ssmods.com/process/src/src/App/Categories.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 | <?php namespace IQnection\BigCommerceApp\App; use SilverStripe\Core\Extension; use SilverStripe\Forms; use SilverStripe\ORM\ValidationException; use IQnection\BigCommerceApp\Model\Category; use IQnection\BigCommerceApp\Cron\BackgroundJob; class Categories extends Main { private static $managed_class = Category::class; private static $url_segment = '_bc/categories'; private static $allowed_actions = [ 'view', 'sync', 'pull', ]; private static $nav_links = [ 'Categories' => [ 'path' => '', 'icon' => 'th-large' ] ]; private static $theme_packages = [ 'forms', ]; public function index() { return $this->Customise([ 'Categories' => Category::get() ]); } public function pull() { if ( (!$record = $this->currentRecord()) || (!$record->Exists()) ) { BackgroundJob::CreateJob(\IQnection\BigCommerceApp\Cron\SyncCategories::class, 'syncCategories'); $this->addAlert('All categories scheduled to sync'); } else { try { $record->SyncFromApi(); $this->addAlert('Data Updated'); } catch (\Exception $e) { $this->addAlert($e->getMessage(),'danger'); } } return $this->redirectBack(); } } |