├── Api ├── GraphqlInterface.php └── InformationInterface.php ├── Controller └── Adminhtml │ └── Setting │ └── Index.php ├── Model ├── Api │ ├── Model │ │ ├── Blog │ │ │ ├── Category.php │ │ │ └── Post.php │ │ ├── Common │ │ │ ├── Address.php │ │ │ ├── Country.php │ │ │ ├── Customer.php │ │ │ ├── Page.php │ │ │ ├── Seo.php │ │ │ ├── Vuefront.php │ │ │ └── Zone.php │ │ ├── Startup │ │ │ └── Startup.php │ │ └── Store │ │ │ ├── Cart.php │ │ │ ├── Category.php │ │ │ ├── Checkout.php │ │ │ ├── Compare.php │ │ │ ├── Manufacturer.php │ │ │ ├── Product.php │ │ │ ├── Review.php │ │ │ └── Wishlist.php │ ├── Resolver │ │ ├── Blog │ │ │ ├── Category.php │ │ │ ├── Post.php │ │ │ └── Review.php │ │ ├── Common │ │ │ ├── Account.php │ │ │ ├── Contact.php │ │ │ ├── Country.php │ │ │ ├── File.php │ │ │ ├── Home.php │ │ │ ├── Language.php │ │ │ ├── Page.php │ │ │ └── Zone.php │ │ ├── Startup │ │ │ └── Startup.php │ │ └── Store │ │ │ ├── Cart.php │ │ │ ├── Category.php │ │ │ ├── Checkout.php │ │ │ ├── Compare.php │ │ │ ├── Currency.php │ │ │ ├── Manufacturer.php │ │ │ ├── Option.php │ │ │ ├── Product.php │ │ │ ├── Review.php │ │ │ └── Wishlist.php │ └── System │ │ ├── Engine │ │ ├── Loader.php │ │ ├── Model.php │ │ ├── Registry.php │ │ └── Resolver.php │ │ ├── Library │ │ ├── Currency.php │ │ ├── Image.php │ │ ├── Response.php │ │ ├── SafeException.php │ │ └── Store.php │ │ └── Startup.php ├── Apps.php ├── GraphqlModel.php ├── InformationModel.php ├── ResourceModel │ ├── Apps.php │ ├── Apps │ │ └── Collection.php │ ├── Settings.php │ └── Settings │ │ └── Collection.php ├── ServiceOutputProcessor.php └── Settings.php ├── Plugin ├── CorsRequestMatchPlugin.php └── CorsRequestOptionsPlugin.php ├── README.md ├── composer.json ├── etc ├── acl.xml ├── adminhtml │ ├── menu.xml │ ├── routes.xml │ └── system.xml ├── config.xml ├── db_schema.xml ├── di.xml ├── email_templates.xml ├── mapping.json ├── module.xml ├── schema.graphql ├── schemaAdmin.graphql └── webapi.xml ├── registration.php └── view ├── adminhtml ├── layout │ ├── default.xml │ └── vuefront_setting_index.xml ├── requirejs-config.js ├── templates │ └── setting.phtml └── web │ ├── css │ ├── admin.css │ ├── bootstrap.css │ ├── bootstrap.css.map │ ├── bootstrap.scss │ ├── bootstrap │ │ ├── _alerts.scss │ │ ├── _badges.scss │ │ ├── _breadcrumbs.scss │ │ ├── _button-groups.scss │ │ ├── _buttons.scss │ │ ├── _carousel.scss │ │ ├── _close.scss │ │ ├── _code.scss │ │ ├── _component-animations.scss │ │ ├── _dropdowns.scss │ │ ├── _forms.scss │ │ ├── _glyphicons.scss │ │ ├── _grid.scss │ │ ├── _input-groups.scss │ │ ├── _jumbotron.scss │ │ ├── _labels.scss │ │ ├── _list-group.scss │ │ ├── _media.scss │ │ ├── _mixins.scss │ │ ├── _modals.scss │ │ ├── _navbar.scss │ │ ├── _navs.scss │ │ ├── _normalize.scss │ │ ├── _pager.scss │ │ ├── _pagination.scss │ │ ├── _panels.scss │ │ ├── _popovers.scss │ │ ├── _print.scss │ │ ├── _progress-bars.scss │ │ ├── _responsive-embed.scss │ │ ├── _responsive-utilities.scss │ │ ├── _scaffolding.scss │ │ ├── _tables.scss │ │ ├── _theme.scss │ │ ├── _thumbnails.scss │ │ ├── _tooltip.scss │ │ ├── _type.scss │ │ ├── _utilities.scss │ │ ├── _variables.scss │ │ ├── _wells.scss │ │ └── mixins │ │ │ ├── _alerts.scss │ │ │ ├── _background-variant.scss │ │ │ ├── _border-radius.scss │ │ │ ├── _buttons.scss │ │ │ ├── _center-block.scss │ │ │ ├── _clearfix.scss │ │ │ ├── _forms.scss │ │ │ ├── _gradients.scss │ │ │ ├── _grid-framework.scss │ │ │ ├── _grid.scss │ │ │ ├── _hide-text.scss │ │ │ ├── _image.scss │ │ │ ├── _labels.scss │ │ │ ├── _list-group.scss │ │ │ ├── _nav-divider.scss │ │ │ ├── _nav-vertical-align.scss │ │ │ ├── _opacity.scss │ │ │ ├── _pagination.scss │ │ │ ├── _panels.scss │ │ │ ├── _progress-bar.scss │ │ │ ├── _reset-filter.scss │ │ │ ├── _reset-text.scss │ │ │ ├── _resize.scss │ │ │ ├── _responsive-visibility.scss │ │ │ ├── _size.scss │ │ │ ├── _tab-focus.scss │ │ │ ├── _table-row.scss │ │ │ ├── _text-emphasis.scss │ │ │ ├── _text-overflow.scss │ │ │ └── _vendor-prefixes.scss │ ├── custom.css │ └── icon.css │ ├── fonts │ ├── icomoon.eot │ ├── icomoon.svg │ ├── icomoon.ttf │ └── icomoon.woff │ ├── images │ └── logo.png │ └── js │ ├── pax │ ├── .babelrc │ ├── .browserslistrc │ ├── .editorconfig │ ├── .eslintrc.js │ ├── assets │ │ ├── img │ │ │ ├── Bottom_image.svg │ │ │ ├── Top_image.svg │ │ │ ├── banned-email.svg │ │ │ ├── bottom-info.svg │ │ │ ├── confirm-email.svg │ │ │ ├── firstBuild.svg │ │ │ ├── footer-modal.svg │ │ │ ├── logo-icon.svg │ │ │ ├── logo.svg │ │ │ ├── profile.png │ │ │ ├── rocket.png │ │ │ ├── rocket.svg │ │ │ ├── top-info.svg │ │ │ └── user.svg │ │ └── scss │ │ │ ├── _colors.scss │ │ │ ├── _modal.scss │ │ │ ├── _variables.scss │ │ │ ├── customMediaVariables.css │ │ │ ├── main.scss │ │ │ └── variables.json │ ├── components │ │ ├── access.vue │ │ ├── activity.vue │ │ ├── alien.vue │ │ ├── apps.vue │ │ ├── banned.vue │ │ ├── banner.vue │ │ ├── check.vue │ │ ├── confirm.vue │ │ ├── development.vue │ │ ├── editApp.vue │ │ ├── firstBuild.vue │ │ ├── header.vue │ │ ├── header │ │ │ ├── Account.vue │ │ │ ├── Activation.vue │ │ │ └── Logo.vue │ │ ├── information.vue │ │ ├── login.vue │ │ ├── modal.vue │ │ ├── rebuild.vue │ │ ├── register.vue │ │ ├── sign-in-banner.vue │ │ ├── signIn.vue │ │ ├── subscription.vue │ │ └── welcome.vue │ ├── core │ │ ├── App.vue │ │ ├── main.js │ │ └── utils │ │ │ ├── i18n.js │ │ │ ├── index.js │ │ │ ├── layouts.js │ │ │ ├── plugins.js │ │ │ ├── router.js │ │ │ └── store.js │ ├── index.html │ ├── layouts │ │ ├── auth.vue │ │ ├── confirm.vue │ │ └── default.vue │ ├── locales │ │ └── en │ │ │ └── index.js │ ├── middleware │ │ ├── alien.js │ │ ├── authenticated.js │ │ ├── banned.js │ │ ├── confirmed.js │ │ ├── noAlien.js │ │ ├── noBanned.js │ │ ├── notAuthenticated.js │ │ ├── notConfirmed.js │ │ └── withEmail.js │ ├── package.json │ ├── pages │ │ └── index.vue │ ├── pax.config.js │ ├── plugins │ │ ├── VeeValidate.js │ │ ├── apollo.js │ │ ├── axios.js │ │ ├── bootstrapVue.js │ │ ├── clipboard.js │ │ ├── cookie.js │ │ ├── fontawesome.js │ │ ├── modal.js │ │ ├── moment.js │ │ └── scrollTo.js │ ├── postcss.config.js │ ├── store │ │ ├── account.js │ │ ├── apollo.js │ │ ├── apps.js │ │ ├── auth.js │ │ ├── cms.js │ │ ├── index.js │ │ ├── information.js │ │ └── settings.js │ ├── webpack-manifest.js │ ├── webpack.config.js │ └── yarn.lock │ └── vuefront │ ├── custom.css │ ├── custom.js │ └── manifest.json └── frontend └── email └── email_template.html /Api/GraphqlInterface.php: -------------------------------------------------------------------------------- 1 | resultPageFactory = $resultPageFactory; 15 | } 16 | 17 | public function execute() 18 | { 19 | return $resultPage = $this->resultPageFactory->create(false, ['test' => 'test']); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Model/Api/Model/Blog/Category.php: -------------------------------------------------------------------------------- 1 | _collectionFactory = $collectionFactory; 17 | $this->_categoryFactory = $categoryFactory; 18 | } 19 | 20 | public function getCategory($category_id) 21 | { 22 | return $this->_categoryFactory->create()->load($category_id); 23 | } 24 | 25 | public function getCategories($data = []) 26 | { 27 | /** @var $collection \Vuefront\Blog\Model\ResourceModel\Category\Collection */ 28 | $collection = $this->_collectionFactory->create(); 29 | 30 | // $collection->addStoreFilter($this->store->getStoreId()); 31 | 32 | if ($data['size'] != '-1') { 33 | $collection->setPageSize($data['size']); 34 | $collection->setCurPage($data['page']); 35 | } 36 | 37 | if ($data['parent'] != -1) { 38 | if ($data['parent'] == 0) { 39 | $collection->addFieldToFilter('parent_id', 0); 40 | } else { 41 | $collection->addFieldToFilter('parent_id', $data['parent']); 42 | } 43 | } 44 | 45 | if (isset($data['order']) && ($data['order'] == 'DESC')) { 46 | $order = "DESC"; 47 | } else { 48 | $order = "ASC"; 49 | } 50 | 51 | $sort_data = [ 52 | 'id' => 'category_id', 53 | 'name' => 'title', 54 | 'sort_order' => 'sort_order' 55 | ]; 56 | 57 | if (isset($data['sort']) && in_array($data['sort'], array_keys($sort_data))) { 58 | $sort = $sort_data[$data['sort']]; 59 | } else { 60 | $sort = "sort_order"; 61 | } 62 | 63 | $collection->setOrder($sort, $order); 64 | 65 | $collection->load(); 66 | 67 | return $collection; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /Model/Api/Model/Blog/Post.php: -------------------------------------------------------------------------------- 1 | _collectionFactory = $collectionFactory; 19 | $this->_postFactory = $postFactory; 20 | $this->_categoryFactory = $categoryFactory; 21 | } 22 | 23 | public function getPost($post_id) 24 | { 25 | return $this->_postFactory->create()->load($post_id); 26 | } 27 | 28 | public function getPosts($data) 29 | { 30 | /** @var $collection \Vuefront\Blog\Model\ResourceModel\Post\Collection */ 31 | $collection = $this->_collectionFactory->create(); 32 | 33 | if ($data['category_id'] != 0) { 34 | $collection->addCategoryFilter($this->_categoryFactory->create()->load($data['category_id'])); 35 | } 36 | 37 | if (isset($data['order']) && ($data['order'] == 'DESC')) { 38 | $order = "DESC"; 39 | } else { 40 | $order = "ASC"; 41 | } 42 | 43 | $sort_data = [ 44 | 'id' => 'post_id', 45 | 'sort_order' => 'date_added' 46 | ]; 47 | 48 | if (isset($data['sort']) && in_array($data['sort'], array_keys($sort_data))) { 49 | $sort = $sort_data[$data['sort']]; 50 | } else { 51 | $sort = "date_added"; 52 | } 53 | 54 | $collection->setOrder($sort, $order); 55 | 56 | $collection->load(); 57 | 58 | return $collection; 59 | } 60 | 61 | public function getNextPost($post_id) 62 | { 63 | /** @var $collection \Vuefront\Blog\Model\ResourceModel\Post\Collection */ 64 | $collection = $this->_collectionFactory->create(); 65 | 66 | $collection->addFieldToFilter('post_id', ['gt' => $post_id]); 67 | 68 | $collection->setOrder('date_added', 'ASC'); 69 | 70 | $collection->load(); 71 | 72 | return $collection; 73 | } 74 | 75 | public function getPrevPost($post_id) 76 | { 77 | /** @var $collection \Vuefront\Blog\Model\ResourceModel\Post\Collection */ 78 | $collection = $this->_collectionFactory->create(); 79 | 80 | $collection->addFieldToFilter('post_id', ['lt' => $post_id]); 81 | 82 | $collection->setOrder('post_id', 'DESC'); 83 | 84 | $collection->load(); 85 | 86 | return $collection; 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /Model/Api/Model/Common/Address.php: -------------------------------------------------------------------------------- 1 | _addressFactory = $addressFactory; 15 | } 16 | 17 | public function addAddress($customer, $data) 18 | { 19 | $address = $this->_addressFactory->create(); 20 | $address->setCity($data['city']); 21 | $address->setCompany($data['company']); 22 | $address->setFirstname($data['firstName']); 23 | $address->setLastname($data['lastName']); 24 | $address->setPostcode($data['zipcode']); 25 | $address->setRegionId($data['zoneId']); 26 | $address->setCountryId($data['countryId']); 27 | $address->setStreet($data['address1'] . ' ' . $data['address2']); 28 | $address->setTelephone(' '); 29 | $address->setCustomer($customer); 30 | $address->save(); 31 | 32 | return $address; 33 | } 34 | 35 | public function editAddress($address_id, $data) 36 | { 37 | $address = $this->_addressFactory->create()->load($address_id); 38 | 39 | $address->setCity($data['city']); 40 | $address->setCompany($data['company']); 41 | $address->setFirstname($data['firstName']); 42 | $address->setLastname($data['lastName']); 43 | $address->setPostcode($data['zipcode']); 44 | $address->setRegionId($data['zoneId']); 45 | $address->setCountryId($data['countryId']); 46 | $address->setStreet($data['address1'] . ' ' . $data['address2']); 47 | $address->setTelephone(' '); 48 | $address->save(); 49 | 50 | return $address; 51 | } 52 | 53 | public function deleteAddress($address_id) 54 | { 55 | $this->_addressFactory->create()->load($address_id)->delete(); 56 | } 57 | 58 | public function getAddress($address_id) 59 | { 60 | return $this->_addressFactory->create()->load($address_id); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /Model/Api/Model/Common/Country.php: -------------------------------------------------------------------------------- 1 | _collectionFactory = $collectionFactory; 17 | $this->_countryFactory = $countryFactory; 18 | } 19 | 20 | public function getCountry($country_id) 21 | { 22 | return $this->_countryFactory->create()->load($country_id); 23 | } 24 | 25 | public function getCountries($data) 26 | { 27 | /** @var $collection \Magento\Directory\Model\ResourceModel\Country\Collection */ 28 | $collection = $this->_collectionFactory->create(); 29 | 30 | if (!empty($data['search'])) { 31 | $collection->join('msp_tfa_country_codes', 'msp_tfa_country_codes.code = main_table.iso2_code'); 32 | $collection->addFieldToFilter('name', ['like' => '%' . $data['search'] . '%']); 33 | } 34 | 35 | if ($data['size'] != '-1') { 36 | $collection->setPageSize($data['size']); 37 | $collection->setCurPage($data['page']); 38 | } 39 | 40 | if (isset($data['order']) && ($data['order'] == 'DESC')) { 41 | $order = "DESC"; 42 | } else { 43 | $order = "ASC"; 44 | } 45 | 46 | $sort_data = [ 47 | 'id' => 'country_id', 48 | 'title' => 'iso2_code' 49 | ]; 50 | 51 | if (isset($data['sort']) && in_array($data['sort'], array_keys($sort_data))) { 52 | $sort = $sort_data[$data['sort']]; 53 | } else { 54 | $sort = "country_id"; 55 | } 56 | 57 | $collection->setOrder($sort, $order); 58 | 59 | $collection->load(); 60 | 61 | return $collection; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /Model/Api/Model/Common/Customer.php: -------------------------------------------------------------------------------- 1 | _collectionFactory = $collectionFactory; 17 | $this->_customerFactory = $customerFactory; 18 | } 19 | 20 | public function getCustomer($customer_id) 21 | { 22 | return $this->_customerFactory->create()->load($customer_id); 23 | } 24 | 25 | public function getCustomers($data) 26 | { 27 | /** @var $collection \Magento\Customer\Model\ResourceModel\Customer\Collection */ 28 | $collection = $this->_collectionFactory->create(); 29 | 30 | if (!empty($data['search'])) { 31 | $collection->addFieldToFilter([ 32 | ['attribute'=>'firstname', 'like' => '%' . $data['search'] . '%'], 33 | ['attribute'=>'lastname', 'like' => '%' . $data['search'] . '%'], 34 | ]); 35 | } 36 | 37 | if ($data['size'] != '-1') { 38 | $collection->setPageSize($data['size']); 39 | $collection->setCurPage($data['page']); 40 | } 41 | 42 | if (isset($data['order']) && ($data['order'] == 'DESC')) { 43 | $order = "DESC"; 44 | } else { 45 | $order = "ASC"; 46 | } 47 | 48 | $sort_data = [ 49 | 'id' => 'entity_id', 50 | 'sort_order' => 'position' 51 | ]; 52 | 53 | if (isset($data['sort']) && in_array($data['sort'], array_keys($sort_data))) { 54 | $sort = $sort_data[$data['sort']]; 55 | } else { 56 | $sort = "entity_id"; 57 | } 58 | 59 | $collection->setOrder($sort, $order); 60 | $collection->load(); 61 | 62 | return $collection; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /Model/Api/Model/Common/Page.php: -------------------------------------------------------------------------------- 1 | _collectionFactory = $collectionFactory; 17 | $this->_pageFactory = $pageFactory; 18 | } 19 | 20 | public function getPage($page_id) 21 | { 22 | return $this->_pageFactory->create()->load($page_id); 23 | } 24 | 25 | public function getPages($data) 26 | { 27 | /** @var $collection \Magento\Cms\Model\ResourceModel\Page\Collection */ 28 | $collection = $this->_collectionFactory->create(); 29 | 30 | if (!empty($data['search'])) { 31 | $collection->addFieldToFilter('title', ['like' => '%' . $data['search'] . '%']); 32 | } 33 | 34 | if ($data['size'] != '-1') { 35 | $collection->setPageSize($data['size']); 36 | $collection->setCurPage($data['page']); 37 | } 38 | 39 | if (isset($data['order']) && ($data['order'] == 'DESC')) { 40 | $order = "DESC"; 41 | } else { 42 | $order = "ASC"; 43 | } 44 | 45 | $sort_data = [ 46 | 'id' => 'page_id', 47 | 'title' => 'title', 48 | 'sort_order' => 'sort_order' 49 | ]; 50 | 51 | if (isset($data['sort']) && in_array($data['sort'], array_keys($sort_data))) { 52 | $sort = $sort_data[$data['sort']]; 53 | } else { 54 | $sort = "sort_order"; 55 | } 56 | 57 | $collection->setOrder($sort, $order); 58 | 59 | $collection->load(); 60 | 61 | return $collection; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /Model/Api/Model/Common/Vuefront.php: -------------------------------------------------------------------------------- 1 | _appsFactory = $appsFactory; 21 | $this->_curl = $curl; 22 | $this->_jsonSerializer = $jsonSerializer; 23 | } 24 | 25 | public function editApp($name, $appSetting) 26 | { 27 | $appSetting['codename'] = $name; 28 | 29 | $app = $this->_appsFactory->create()->getCollection(); 30 | $app->addFieldToSelect('*'); 31 | $app->addFieldToFilter('codename', ['like' => $name]); 32 | $result = $app->load(); 33 | 34 | $model = $result->getFirstItem(); 35 | 36 | foreach ($appSetting as $key => $value) { 37 | $model->setData($key, $value); 38 | } 39 | 40 | $model->save(); 41 | } 42 | 43 | public function getApp($name) 44 | { 45 | $collection = $this->_appsFactory->create()->getCollection(); 46 | 47 | foreach ($collection as $key => $value) { 48 | $data = $value->getData(); 49 | 50 | if ($data['codename'] == $codename) { 51 | return $value->getData(); 52 | } 53 | } 54 | 55 | return false; 56 | } 57 | 58 | public function getAppsForEvent() 59 | { 60 | $collection = $this->_appsFactory->create()->getCollection(); 61 | 62 | $result = []; 63 | foreach ($collection as $key => $value) { 64 | if (!empty($value['eventUrl'])) { 65 | $result[] = $value; 66 | } 67 | } 68 | 69 | return $result; 70 | } 71 | 72 | public function pushEvent($name, $data) 73 | { 74 | $apps = $this->getAppsForEvent(); 75 | 76 | foreach ($apps as $key => $value) { 77 | $output = $this->request($value['eventUrl'], [ 78 | 'name' => $name, 79 | 'data' => $data, 80 | ]); 81 | 82 | if ($output) { 83 | $data = $output; 84 | } 85 | } 86 | 87 | return $data; 88 | } 89 | 90 | public function request($url, $data, $token = false) 91 | { 92 | $this->_curl->addHeader('Content-type', 'application/json'); 93 | 94 | if ($token) { 95 | $this->_curl->addHeader('Authorization', ' Bearer '.$token); 96 | } 97 | 98 | $this->_curl->post($url, $this->_jsonSerializer->serialize($data)); 99 | 100 | $result = $this->_curl->getBody(); 101 | 102 | $result = $this->_jsonSerializer->unserialize($result); 103 | 104 | return $result; 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /Model/Api/Model/Common/Zone.php: -------------------------------------------------------------------------------- 1 | _collectionFactory = $collectionFactory; 17 | $this->_regionFactory = $regionFactory; 18 | } 19 | 20 | public function getZone($zone_id) 21 | { 22 | return $this->_regionFactory->create()->load($zone_id); 23 | } 24 | 25 | public function getZones($data) 26 | { 27 | /** @var $collection \Magento\Directory\Model\ResourceModel\Region\Collection */ 28 | $collection = $this->_collectionFactory->create(); 29 | 30 | if (!empty($data['search'])) { 31 | $collection->addFieldToFilter('name', ['like' => '%' . $data['search'] . '%']); 32 | } 33 | if (!empty($data['country_id'])) { 34 | $collection->addFieldToFilter('country_id', $data['country_id']); 35 | } 36 | 37 | if ($data['size'] != '-1') { 38 | $collection->setPageSize($data['size']); 39 | $collection->setCurPage($data['page']); 40 | } 41 | 42 | if (isset($data['order']) && ($data['order'] == 'DESC')) { 43 | $order = "DESC"; 44 | } else { 45 | $order = "ASC"; 46 | } 47 | 48 | $sort_data = [ 49 | 'id' => 'region_id', 50 | 'title' => 'name' 51 | ]; 52 | 53 | if (isset($data['sort']) && in_array($data['sort'], array_keys($sort_data))) { 54 | $sort = $sort_data[$data['sort']]; 55 | } else { 56 | $sort = "region_id"; 57 | } 58 | 59 | $collection->setOrder($sort, $order); 60 | $collection->load(); 61 | 62 | return $collection; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /Model/Api/Model/Store/Category.php: -------------------------------------------------------------------------------- 1 | _collectionFactory = $collectionFactory; 17 | $this->_categoryFactory = $categoryFactory; 18 | } 19 | 20 | public function getCategory($category_id) 21 | { 22 | return $this->_categoryFactory->create()->load($category_id); 23 | } 24 | 25 | public function getCategories($data = []) 26 | { 27 | $collection = $this->_collectionFactory->create(); 28 | 29 | $collection->addAttributeToSelect('*'); 30 | 31 | if (!empty($data['search'])) { 32 | $collection->addFieldToFilter('name', ['like' => '%' . $data['search'] . '%']); 33 | } 34 | 35 | if ($data['top']) { 36 | $collection->addAttributeToFilter('include_in_menu', ['eq' => $data['top'] ? 1 : 0]); 37 | } 38 | 39 | if ($data['size'] != '-1') { 40 | $collection->setPage($data['page'], $data['size']); 41 | } 42 | 43 | $collection->addFieldToFilter('is_active', 1); 44 | 45 | if ($data['parent'] != -1) { 46 | if ($data['parent'] == 0) { 47 | $collection->addFieldToFilter('parent_id', $this->store->getRootCategoryId()); 48 | } else { 49 | $collection->addFieldToFilter('parent_id', $data['parent']); 50 | } 51 | } 52 | 53 | if (isset($data['order']) && ($data['order'] == 'DESC')) { 54 | $order = "DESC"; 55 | } else { 56 | $order = "ASC"; 57 | } 58 | 59 | $sort_data = [ 60 | 'id' => 'entity_id', 61 | 'sort_order' => 'position' 62 | ]; 63 | 64 | if (isset($data['sort']) && in_array($data['sort'], array_keys($sort_data))) { 65 | $sort = $sort_data[$data['sort']]; 66 | } else { 67 | $sort = "position"; 68 | } 69 | 70 | $collection->setOrder($sort, $order); 71 | 72 | $collection->load(); 73 | 74 | return $collection; 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /Model/Api/Model/Store/Checkout.php: -------------------------------------------------------------------------------- 1 | _appsFactory = $appsFactory; 21 | $this->_curl = $curl; 22 | $this->_jsonSerializer = $jsonSerializer; 23 | } 24 | 25 | public function getJwt($codename) 26 | { 27 | 28 | $collection = $this->_appsFactory->create()->getCollection(); 29 | 30 | $jwt = ''; 31 | 32 | foreach ($collection as $key => $value) { 33 | $data = $value->getData(); 34 | 35 | if ($data['codename'] == $codename) { 36 | $jwt = $data['jwt']; 37 | } 38 | } 39 | 40 | return $jwt; 41 | } 42 | 43 | public function requestCheckout($query, $variables) 44 | { 45 | $jwt = $this->getJwt('vuefront-checkout-app'); 46 | 47 | $requestData = [ 48 | 'operationName' => null, 49 | 'variables' => $variables, 50 | 'query' => $query 51 | ]; 52 | 53 | $headr = []; 54 | 55 | $headr[] = 'Content-type: application/json'; 56 | $headr[] = 'Authorization: '.$jwt; 57 | 58 | $this->_curl->addHeader('Content-type', 'application/json'); 59 | $this->_curl->addHeader('Authorization', $jwt); 60 | $this->_curl->setOption(CURLOPT_SSL_VERIFYHOST, false); 61 | $this->_curl->setOption(CURLOPT_SSL_VERIFYPEER, false); 62 | $this->_curl->post( 63 | 'https://api.checkout.vuefront.com/graphql', 64 | $this->_jsonSerializer->serialize($requestData) 65 | ); 66 | 67 | $result = $this->_curl->getBody(); 68 | 69 | $result = $this->_jsonSerializer->unserialize($result); 70 | 71 | return $result['data']; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /Model/Api/Model/Store/Compare.php: -------------------------------------------------------------------------------- 1 | _sessionManager = $sessionManager; 18 | } 19 | 20 | public function getCompare() 21 | { 22 | $result = []; 23 | 24 | if (!empty($this->_sessionManager->getCompare())) { 25 | $result = $this->_sessionManager->getCompare(); 26 | } 27 | 28 | return $result; 29 | } 30 | 31 | public function addCompare($product_id) 32 | { 33 | 34 | $compare = $this->_sessionManager->getCompare(); 35 | 36 | if (!$compare) { 37 | $compare = []; 38 | } 39 | 40 | if (!in_array($product_id, $compare)) { 41 | if (count($compare) >= 4) { 42 | array_shift($compare); 43 | } 44 | $compare[] = (int)$product_id; 45 | } 46 | 47 | $this->_sessionManager->setCompare($compare); 48 | } 49 | 50 | public function deleteCompare($product_id) 51 | { 52 | if ($this->_sessionManager->getCompare()) { 53 | $compare = $this->_sessionManager->getCompare(); 54 | $key = array_search($product_id, $compare); 55 | 56 | if ($key !== false) { 57 | unset($compare[$key]); 58 | } 59 | $this->_sessionManager->setCompare($compare); 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /Model/Api/Model/Store/Manufacturer.php: -------------------------------------------------------------------------------- 1 | _collectionFactory = $collectionFactory; 33 | $this->_manufacturerFactory = $manufacturerFactory; 34 | $this->_resourceBrand = $resourceBrand; 35 | } 36 | 37 | public function getManufacturer($manufacturer_id) 38 | { 39 | return $this->_manufacturerFactory->create()->load($manufacturer_id); 40 | } 41 | 42 | public function getManufacturerByProduct($product_id) 43 | { 44 | $table = $this->_resourceBrand->getTable('vuefront_brands_brand_product'); 45 | $brandData = $this->_resourceBrand->getConnection()-> 46 | select()-> 47 | from($table)-> 48 | where('product_id='.$product_id)-> 49 | query()-> 50 | fetch(); 51 | $brandId = 0; 52 | if ($brandData) { 53 | $brandId = $brandData['brand_id']; 54 | } 55 | 56 | return $brandId; 57 | } 58 | 59 | public function getManufacturers($data = []) 60 | { 61 | $collection = $this->_collectionFactory->create(); 62 | 63 | $collection->addFieldToSelect('*'); 64 | 65 | if (!empty($data['search'])) { 66 | $collection->addFieldToFilter('name', ['like' => '%' . $data['search'] . '%']); 67 | } 68 | 69 | if ($data['size'] != '-1') { 70 | $collection->setPageSize($data['size']); 71 | $collection->setCurPage($data['page']); 72 | } 73 | 74 | if (isset($data['order']) && ($data['order'] == 'DESC')) { 75 | $order = "DESC"; 76 | } else { 77 | $order = "ASC"; 78 | } 79 | 80 | $sort_data = [ 81 | 'id' => 'brand_id', 82 | 'sort_order' => 'date_added' 83 | ]; 84 | 85 | if (isset($data['sort']) && in_array($data['sort'], array_keys($sort_data))) { 86 | $sort = $sort_data[$data['sort']]; 87 | } else { 88 | $sort = "date_added"; 89 | } 90 | 91 | $collection->setOrder("`" . $sort . "`", $order); 92 | 93 | $collection->load(); 94 | 95 | return $collection; 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /Model/Api/Model/Store/Review.php: -------------------------------------------------------------------------------- 1 | _collectionFactory = $collectionFactory; 15 | } 16 | 17 | public function getReviews($product_id) 18 | { 19 | /** @var $collection \Magento\Review\Model\ResourceModel\Review\Collection */ 20 | $collection = $this->_collectionFactory->create(); 21 | 22 | $collection->addStoreFilter( 23 | $this->store->getStoreId() 24 | )->addStatusFilter( 25 | \Magento\Review\Model\Review::STATUS_APPROVED 26 | )->addEntityFilter( 27 | 'product', 28 | $product_id 29 | )->setDateOrder(); 30 | 31 | $collection->load(); 32 | 33 | $collection->addRateVotes(); 34 | 35 | return $collection; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Model/Api/Model/Store/Wishlist.php: -------------------------------------------------------------------------------- 1 | _sessionManager = $sessionManager; 18 | } 19 | 20 | public function getWishlist() 21 | { 22 | $result = []; 23 | 24 | if (!empty($this->_sessionManager->getWishList())) { 25 | $result = $this->_sessionManager->getWishList(); 26 | } 27 | 28 | return $result; 29 | } 30 | 31 | public function addWishlist($product_id) 32 | { 33 | $wishList = $this->_sessionManager->getWishList(); 34 | 35 | if (!$wishList) { 36 | $wishList = []; 37 | } 38 | 39 | if (!in_array($product_id, $wishList)) { 40 | $wishList[] = (int)$product_id; 41 | } 42 | 43 | $this->_sessionManager->setWishList($wishList); 44 | } 45 | 46 | public function deleteWishlist($product_id) 47 | { 48 | if ($this->_sessionManager->getWishList()) { 49 | $wishList = $this->_sessionManager->getWishList(); 50 | $key = array_search($product_id, $wishList); 51 | 52 | if ($key !== false) { 53 | unset($wishList[$key]); 54 | } 55 | 56 | $this->_sessionManager->setWishList($wishList); 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /Model/Api/Resolver/Blog/Review.php: -------------------------------------------------------------------------------- 1 | _commentFactory = $commentFactory; 28 | $this->_session = $session; 29 | $this->_scopeConfig = $scopeConfig; 30 | } 31 | 32 | public function add($args) 33 | { 34 | $comment = $this->_commentFactory->create(); 35 | $comment->setData([ 36 | 'post_id' => $args['id'], 37 | 'rating' => $args['rating'], 38 | 'author' => $args['author'], 39 | 'description' => $args['content'] 40 | ]); 41 | 42 | $comment->setStatus(0); 43 | 44 | $comment->save(); 45 | 46 | return $this->load->resolver('blog/post/get', $args); 47 | } 48 | 49 | public function get($data) 50 | { 51 | /** @var $post \Vuefront\Blog\Model\Post */ 52 | $post = $data['post']; 53 | /** @var \Vuefront\Blog\Model\ResourceModel\Comment\Collection $collection */ 54 | $collection = $post->getComments(); 55 | 56 | $comments = []; 57 | /** @var \Vuefront\Blog\Model\Comment $comment */ 58 | foreach ($collection->getItems() as $comment) { 59 | $comments[] = [ 60 | 'author' => $comment->getAuthor(), 61 | 'author_email' => '', 62 | 'created_at' => $comment->getDateAdded(), 63 | 'content' => $comment->getDescription(), 64 | 'rating' => $comment->getRating() 65 | ]; 66 | } 67 | 68 | return [ 69 | 'content' => $comments, 70 | 'totalElements' => $post->getCommentsCount() 71 | ]; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /Model/Api/Resolver/Common/Contact.php: -------------------------------------------------------------------------------- 1 | _scopeConfig = $scopeConfig; 31 | $this->_stateModel = $stateModel; 32 | $this->_transportBuilder = $transportBuilder; 33 | } 34 | 35 | public function get() 36 | { 37 | return [ 38 | 'store' => $this->_scopeConfig->getValue('general/store_information/name', ScopeInterface::SCOPE_STORE), 39 | 'email' => $this->_scopeConfig->getValue('trans_email/ident_general/email', ScopeInterface::SCOPE_STORE), 40 | 'address' => $this->store->getFormattedAddress(), 41 | 'geocode' => '', 42 | 'locations' => [], 43 | 'telephone' => $this->_scopeConfig 44 | ->getValue('general/store_information/phone', ScopeInterface::SCOPE_STORE), 45 | 'fax' => '', 46 | 'open' => $this->_scopeConfig->getValue('general/store_information/hours', ScopeInterface::SCOPE_STORE), 47 | 'comment' => '' 48 | ]; 49 | } 50 | 51 | public function send($args) 52 | { 53 | $this->_stateModel->suspend(); 54 | try { 55 | $sender = [ 56 | 'name' => $args['name'], 57 | 'email' => $args['email'], 58 | ]; 59 | 60 | $storeScope = ScopeInterface::SCOPE_STORE; 61 | $transport = $this->_transportBuilder 62 | ->setTemplateIdentifier('send_email_email_template') 63 | ->setTemplateOptions( 64 | [ 65 | 'area' => Area::AREA_FRONTEND, 66 | 'store' => Store::DEFAULT_STORE_ID, 67 | ] 68 | ) 69 | ->setTemplateVars($args) 70 | ->setFrom($sender) 71 | ->addTo($this->_scopeConfig->getValue('trans_email/ident_general/email', $storeScope)) 72 | ->getTransport(); 73 | 74 | $transport->sendMessage(); 75 | $this->_stateModel->resume(); 76 | } catch (\Exception $e) { 77 | $this->_stateModel->resume(); 78 | throw new \Magento\Framework\Exception\MailException(__($e->getMessage())); 79 | } 80 | 81 | return [ 82 | "status" => true 83 | ]; 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /Model/Api/Resolver/Common/Country.php: -------------------------------------------------------------------------------- 1 | load->model('common/country'); 14 | 15 | /** @var $country \Magento\Directory\Model\Country */ 16 | if (!isset($args['country'])) { 17 | $country = $this->model_common_country->getCountry($args['id']); 18 | } else { 19 | $country = $args['country']; 20 | } 21 | 22 | return [ 23 | 'id' => function () use ($country) { 24 | return $country->getId(); 25 | }, 26 | 'name' => function () use ($country) { 27 | return $country->getName(); 28 | } 29 | ]; 30 | } 31 | 32 | public function getList($args) 33 | { 34 | $this->load->model('common/country'); 35 | $countries = []; 36 | 37 | /** @var $collection \Magento\Directory\Model\ResourceModel\Country\Collection */ 38 | $collection = $this->model_common_country->getCountries($args); 39 | $country_total = $collection->getSize(); 40 | 41 | foreach ($collection->getItems() as $value) { 42 | $countries[] = $this->get(['country' => $value]); 43 | } 44 | 45 | return [ 46 | 'content' => $countries, 47 | 'first' => $args['page'] === 1, 48 | 'last' => $args['page'] === ceil($country_total / $args['size']), 49 | 'number' => (int)$args['page'], 50 | 'numberOfElements' => count($countries), 51 | 'size' => (int)$args['size'], 52 | 'totalPages' => (int)ceil($country_total / $args['size']), 53 | 'totalElements' => (int)$country_total, 54 | ]; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /Model/Api/Resolver/Common/File.php: -------------------------------------------------------------------------------- 1 | 'English', 17 | 'code' => 'en-gb', 18 | 'image' => '', 19 | 'active' => true 20 | ]; 21 | 22 | return $languages; 23 | } 24 | 25 | public function edit($args) 26 | { 27 | return $this->get(); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Model/Api/Resolver/Common/Page.php: -------------------------------------------------------------------------------- 1 | load->model('common/page'); 12 | 13 | /** @var $page \Magento\Cms\Model\Page */ 14 | if (!isset($args['page'])) { 15 | $page = $this->model_common_page->getPage($args['id']); 16 | } else { 17 | $page = $args['page']; 18 | } 19 | 20 | return [ 21 | 'id' => function () use ($page) { 22 | return $page->getId(); 23 | }, 24 | 'title' => function () use ($page) { 25 | return $page->getTitle(); 26 | }, 27 | 'name' => function () use ($page) { 28 | return $page->getTitle(); 29 | }, 30 | 'description' => function () use ($page) { 31 | return $page->getContent(); 32 | }, 33 | 'sort_order' => function () use ($page) { 34 | return $page->getSortOrder(); 35 | }, 36 | 'keyword' => function () use ($page) { 37 | return $page->getIdentifier(); 38 | }, 39 | 'url' => function ($root, $args) use ($page) { 40 | return $this->url([ 41 | 'parent' => $root, 42 | 'args' => $args, 43 | 'page' => $page 44 | ]); 45 | }, 46 | 'meta' => function () use ($page) { 47 | return [ 48 | 'title' => $page->getMetaTitle() != '' ? $page->getMetaTitle() : $page->getTitle(), 49 | 'description' => $page->getMetaDescription() ? $page->getMetaDescription() : '', 50 | 'keyword' => $page->getMetaKeywords() ? $page->getMetaKeywords() : '' 51 | ]; 52 | } 53 | ]; 54 | } 55 | 56 | public function getList($args) 57 | { 58 | $this->load->model('common/page'); 59 | 60 | /** @var $collection \Magento\Cms\Model\ResourceModel\Page\Collection */ 61 | $collection = $this->model_common_page->getPages($args); 62 | 63 | $page_total = $collection->getSize(); 64 | 65 | $pages = []; 66 | 67 | foreach ($collection->getItems() as $page) { 68 | $pages[] = $this->get(['page' => $page]); 69 | } 70 | 71 | return [ 72 | 'content' => $pages, 73 | 'first' => $args['page'] === 1, 74 | 'last' => $args['page'] === ceil($page_total / $args['size']), 75 | 'number' => (int)$args['page'], 76 | 'numberOfElements' => count($pages), 77 | 'size' => (int)$args['size'], 78 | 'totalPages' => (int)ceil($page_total / $args['size']), 79 | 'totalElements' => (int)$page_total, 80 | ]; 81 | } 82 | 83 | public function url($data) 84 | { 85 | /** @var $page_info \Magento\Cms\Model\Page */ 86 | $page_info = $data['page']; 87 | $result = $data['args']['url']; 88 | 89 | $result = str_replace("_id", $page_info->getId(), $result); 90 | $result = str_replace("_name", $page_info->getTitle(), $result); 91 | 92 | if ($page_info->getIdentifier() != "") { 93 | $result = '/' . $page_info->getIdentifier(); 94 | } 95 | 96 | return $result; 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /Model/Api/Resolver/Common/Zone.php: -------------------------------------------------------------------------------- 1 | load->model('common/zone'); 14 | 15 | /** @var $zone \Magento\Directory\Model\Region */ 16 | if (!isset($args['zone'])) { 17 | $zone = $this->model_common_zone->getZone($args['id']); 18 | } else { 19 | $zone = $args['zone']; 20 | } 21 | 22 | return [ 23 | 'id' => function () use ($zone) { 24 | return $zone->getId(); 25 | }, 26 | 'name' => function () use ($zone) { 27 | return $zone->getName(); 28 | }, 29 | 'countryId' => function () use ($zone) { 30 | return $zone->getCountryId(); 31 | } 32 | ]; 33 | } 34 | 35 | public function getList($args) 36 | { 37 | $this->load->model('common/zone'); 38 | $zones = []; 39 | 40 | /** @var $collection \Magento\Directory\Model\ResourceModel\Region\Collection */ 41 | $collection = $this->model_common_zone->getZones($args); 42 | $zone_total = $collection->getSize(); 43 | 44 | foreach ($collection->getItems() as $value) { 45 | $zones[] = $this->get(['zone' => $value]); 46 | } 47 | 48 | return [ 49 | 'content' => $zones, 50 | 'first' => $args['page'] === 1, 51 | 'last' => $args['page'] === ceil($zone_total / $args['size']), 52 | 'number' => (int)$args['page'], 53 | 'numberOfElements' => count($zones), 54 | 'size' => (int)$args['size'], 55 | 'totalPages' => (int)ceil($zone_total / $args['size']), 56 | 'totalElements' => (int)$zone_total, 57 | ]; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /Model/Api/Resolver/Startup/Startup.php: -------------------------------------------------------------------------------- 1 | load->model('startup/startup'); 14 | 15 | try { 16 | $query = $input['query']; 17 | $sources = [$this->model_startup_startup->getSchema()]; 18 | if ($this->model_startup_startup->checkAccess()) { 19 | $sources[] = $this->model_startup_startup->getAdminSchema(); 20 | } 21 | 22 | $source = $this->model_startup_startup->mergeSchemas($sources); 23 | $source = $this->model_startup_startup->parseSchema($source); 24 | $resolvers = $this->model_startup_startup->getResolvers(); 25 | 26 | $schema = BuildSchema::build($source); 27 | 28 | $variableValues = isset($input['variables']) ? $input['variables'] : null; 29 | $result = GraphQL::executeQuery($schema, $query, $resolvers, null, $variableValues)->toArray(); 30 | } catch (\Exception $e) { 31 | $result = [ 32 | 'error' => [ 33 | 'message' => $e->getMessage() 34 | ] 35 | ]; 36 | } 37 | 38 | $this->response->setOutput($result); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Model/Api/Resolver/Store/Compare.php: -------------------------------------------------------------------------------- 1 | load->model('store/compare'); 12 | 13 | $this->model_store_compare->addCompare($args['id']); 14 | 15 | return $this->get(); 16 | } 17 | 18 | public function remove($args) 19 | { 20 | $this->load->model('store/compare'); 21 | $this->model_store_compare->deleteCompare($args['id']); 22 | 23 | return $this->get(); 24 | } 25 | 26 | public function get($args = []) 27 | { 28 | $this->load->model('store/compare'); 29 | $compare = []; 30 | $results = $this->model_store_compare->getCompare(); 31 | 32 | foreach ($results as $product_id) { 33 | $compare[] = $this->load->resolver('store/product/get', ['id' => $product_id]); 34 | } 35 | 36 | return $compare; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Model/Api/Resolver/Store/Currency.php: -------------------------------------------------------------------------------- 1 | _currencyModel = $currencyModel; 28 | $this->_currencyBundle = $currencyBundle; 29 | $this->_resolverModel = $resolverModel; 30 | } 31 | 32 | public function get() 33 | { 34 | $currencies = []; 35 | 36 | foreach ($this->_currencyModel->getConfigAllowCurrencies() as $code) { 37 | $allCurrencies = $this->_currencyBundle->get( 38 | $this->_resolverModel->getLocale() 39 | )['Currencies']; 40 | 41 | $currency = $this->_currencyModel->load($code); 42 | 43 | $currencies[] = [ 44 | 'title' => $allCurrencies[$code][1] ?: $code, 45 | 'name' => $allCurrencies[$code][1] ?: $code, 46 | 'code' => $code, 47 | 'symbol_left' => $currency->getCurrencySymbol(), 48 | 'symbol_right' => '', 49 | 'active' => $code == $this->store->getCurrencyCode() 50 | ]; 51 | } 52 | 53 | return $currencies; 54 | } 55 | 56 | public function edit($args) 57 | { 58 | $this->store->setCurrencyCode($args['code']); 59 | return $this->get(); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /Model/Api/Resolver/Store/Option.php: -------------------------------------------------------------------------------- 1 | _ratingFactory = $ratingFactory; 20 | $this->_reviewFactory = $reviewFactory; 21 | } 22 | 23 | public function add($args) 24 | { 25 | $productId = $args['id']; 26 | $reviewFinalData['ratings'][1] = $args['rating']; 27 | $reviewFinalData['nickname'] = $args['author']; 28 | $reviewFinalData['title'] = ""; 29 | $reviewFinalData['detail'] = $args['content']; 30 | $review = $this->_reviewFactory->create()->setData($reviewFinalData); 31 | $review->unsetData('review_id'); 32 | $review->setEntityId($review->getEntityIdByCode(\Magento\Review\Model\Review::ENTITY_PRODUCT_CODE)) 33 | ->setEntityPkValue($productId) 34 | ->setStatusId(\Magento\Review\Model\Review::STATUS_APPROVED) 35 | ->setStoreId($this->store->getStoreId()) 36 | ->setStores([$this->store->getStoreId()]) 37 | ->save(); 38 | 39 | foreach ($reviewFinalData['ratings'] as $ratingId => $optionId) { 40 | $this->_ratingFactory->create() 41 | ->setRatingId($ratingId) 42 | ->setReviewId($review->getId()) 43 | ->addOptionVote($optionId, $productId); 44 | } 45 | $review->aggregate(); 46 | 47 | return $this->load->resolver('store/product/get', $args); 48 | } 49 | 50 | public function get($data) 51 | { 52 | $this->load->model('store/review'); 53 | /** @var $product \Magento\Catalog\Model\Product */ 54 | $product = $data['product']; 55 | /** @var $collection \Magento\Review\Model\ResourceModel\Review\Collection */ 56 | $collection = $this->model_store_review->getReviews($product->getId()); 57 | 58 | $comments = []; 59 | 60 | /** @var \Magento\Review\Model\Review $comment */ 61 | foreach ($collection->getItems() as $comment) { 62 | $avg = 0; 63 | if (count($comment->getRatingVotes())) { 64 | $ratings = []; 65 | foreach ($comment->getRatingVotes() as $rating) { 66 | $ratings[] = $rating->getPercent(); 67 | } 68 | $avg = array_sum($ratings) / count($ratings); 69 | } 70 | 71 | $comments[] = [ 72 | 'author' => $comment->getData('nickname'), 73 | 'author_email' => '', 74 | 'created_at' => $comment->getData('created_at'), 75 | 'content' => $comment->getData('detail'), 76 | 'rating' => (float)$avg * 5 / 100 77 | ]; 78 | } 79 | 80 | return $comments; 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /Model/Api/Resolver/Store/Wishlist.php: -------------------------------------------------------------------------------- 1 | load->model('store/wishlist'); 12 | 13 | $this->model_store_wishlist->addWishlist($args['id']); 14 | 15 | return $this->getList(); 16 | } 17 | 18 | public function remove($args) 19 | { 20 | $this->load->model('store/wishlist'); 21 | $this->model_store_wishlist->deleteWishlist($args['id']); 22 | 23 | return $this->getList(); 24 | } 25 | 26 | public function getList($args = []) 27 | { 28 | $this->load->model('store/wishlist'); 29 | $wishlist = []; 30 | $results = $this->model_store_wishlist->getWishlist(); 31 | 32 | foreach ($results as $product_id) { 33 | $wishlist[] = $this->load->resolver('store/product/get', ['id' => $product_id]); 34 | } 35 | 36 | return $wishlist; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Model/Api/System/Engine/Model.php: -------------------------------------------------------------------------------- 1 | registry = $registry; 20 | } 21 | 22 | public function __get($key) 23 | { 24 | return $this->registry->get($key); 25 | } 26 | 27 | public function __set($key, $value) 28 | { 29 | $this->registry->set($key, $value); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Model/Api/System/Engine/Registry.php: -------------------------------------------------------------------------------- 1 | data[$key]) ? $this->data[$key] : null); 11 | } 12 | 13 | public function set($key, $value) 14 | { 15 | $this->data[$key] = $value; 16 | } 17 | 18 | public function has($key) 19 | { 20 | return isset($this->data[$key]); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Model/Api/System/Engine/Resolver.php: -------------------------------------------------------------------------------- 1 | registry = $registry; 25 | } 26 | 27 | public function __get($key) 28 | { 29 | return $this->registry->get($key); 30 | } 31 | 32 | public function __set($key, $value) 33 | { 34 | $this->registry->set($key, $value); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Model/Api/System/Library/Currency.php: -------------------------------------------------------------------------------- 1 | currency = $currency; 13 | } 14 | 15 | public function format($price) 16 | { 17 | return $this->currency->currency($price, true, false); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Model/Api/System/Library/Image.php: -------------------------------------------------------------------------------- 1 | storeManager = $storeManager; 25 | $this->imageFactory = $imageFactory; 26 | $this->_fileSystem = $filesystem; 27 | $this->_directory = $this->_fileSystem->getDirectoryWrite(DirectoryList::MEDIA); 28 | } 29 | 30 | public function resize($imageName, $width = 258, $height = 200, $prefix = 'catalog/product') 31 | { 32 | $absolutePath = $this->_fileSystem 33 | ->getDirectoryRead(\Magento\Framework\App\Filesystem\DirectoryList::ROOT) 34 | ->getAbsolutePath('/pub/media/') . $imageName; 35 | $absolutePath = str_replace('//media/', '/', $absolutePath); 36 | $imageResized = $this->_fileSystem 37 | ->getDirectoryRead(\Magento\Framework\App\Filesystem\DirectoryList::MEDIA) 38 | ->getAbsolutePath('resized/' . $width . '/') . $imageName; 39 | $imageResized = str_replace('//', '/', $imageResized); 40 | $imageResize = $this->imageFactory->create(); 41 | $imageResize->open($absolutePath); 42 | $imageResize->constrainOnly(true); 43 | $imageResize->keepTransparency(true); 44 | $imageResize->keepFrame(false); 45 | $imageResize->keepAspectRatio(true); 46 | $imageResize->resize($width, $height); 47 | $destination = $imageResized; 48 | $imageResize->save($destination); 49 | 50 | $resizedURL = $this->storeManager->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA) 51 | . 'resized/' . $width . '/' . $imageName; 52 | 53 | return $resizedURL; 54 | } 55 | 56 | public function getUrl($imagePath, $prefix = 'catalog/product') 57 | { 58 | return $this->storeManager->getStore()->getBaseUrl(UrlInterface::URL_TYPE_MEDIA) . $prefix . $imagePath; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /Model/Api/System/Library/Response.php: -------------------------------------------------------------------------------- 1 | output = $output; 11 | } 12 | 13 | public function getOutput() 14 | { 15 | return $this->output; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Model/Api/System/Library/SafeException.php: -------------------------------------------------------------------------------- 1 | storeManager = $storeManager; 13 | } 14 | 15 | public function getBaseUrl() 16 | { 17 | return $this->storeManager->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA); 18 | } 19 | 20 | public function getStoreId() 21 | { 22 | return $this->storeManager->getStore()->getId(); 23 | } 24 | 25 | public function getWebsiteId() 26 | { 27 | return $this->storeManager->getStore()->getWebsiteId(); 28 | } 29 | 30 | public function getName() 31 | { 32 | return $this->storeManager->getStore()->getName(); 33 | } 34 | 35 | public function getFormattedAddress() 36 | { 37 | return $this->storeManager->getStore()->getFormattedAddress(); 38 | } 39 | 40 | public function getCurrencyCode() 41 | { 42 | return $this->storeManager->getStore()->getCurrentCurrency()->getCode(); 43 | } 44 | 45 | public function setCurrencyCode($currency) 46 | { 47 | $this->storeManager->getStore()->setCurrentCurrencyCode($currency); 48 | } 49 | 50 | public function getLocale() 51 | { 52 | return $this->storeManager->getStore()->getLocale(); 53 | } 54 | 55 | public function getRootCategoryId() 56 | { 57 | return $this->storeManager->getStore()->getRootCategoryId(); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /Model/Api/System/Startup.php: -------------------------------------------------------------------------------- 1 | loader = $loader; 22 | $this->registry = $registry; 23 | $this->registry->set('load', $loader); 24 | $this->registry->set('currency', $currency); 25 | $this->registry->set('image', $image); 26 | $this->registry->set('response', $response); 27 | $this->registry->set('store', $store); 28 | $this->registry->set('driver', $driver); 29 | } 30 | 31 | /** 32 | * @param $body 33 | * @param $driver \Magento\Framework\Filesystem\Driver\File 34 | */ 35 | public function start($body, $driver) 36 | { 37 | $this->loader->resolver('startup/startup', $body); 38 | 39 | return $this->registry->get('response')->getOutput(); 40 | } 41 | 42 | /** 43 | * @param $body 44 | * @param $driver \Magento\Framework\Filesystem\Driver\File 45 | * @param $orderId 46 | */ 47 | public function callback($body, $driver, $orderId) 48 | { 49 | $this->loader->resolver('store/checkout/callback', ['body' => $body, 'orderId' => $orderId]); 50 | 51 | return $this->registry->get('response')->getOutput(); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Model/Apps.php: -------------------------------------------------------------------------------- 1 | _init(\Vuefront\Vuefront\Model\ResourceModel\Apps::class); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Model/ResourceModel/Apps.php: -------------------------------------------------------------------------------- 1 | _init('vuefront_apps', 'app_id'); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Model/ResourceModel/Apps/Collection.php: -------------------------------------------------------------------------------- 1 | _init( 11 | \Vuefront\Vuefront\Model\Apps::class, 12 | \Vuefront\Vuefront\Model\ResourceModel\Apps::class 13 | ); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Model/ResourceModel/Settings.php: -------------------------------------------------------------------------------- 1 | _init('vuefront_settings', 'setting_id'); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Model/ResourceModel/Settings/Collection.php: -------------------------------------------------------------------------------- 1 | _init( 11 | \Vuefront\Vuefront\Model\Settings::class, 12 | \Vuefront\Vuefront\Model\ResourceModel\Settings::class 13 | ); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Model/ServiceOutputProcessor.php: -------------------------------------------------------------------------------- 1 | methodsMapProcessor->getMethodReturnType($serviceClassName, $serviceMethodName); 21 | if ($serviceClassName == \Vuefront\Vuefront\Api\GraphqlInterface::class) { 22 | return $data; 23 | } elseif ($serviceClassName == \Vuefront\Vuefront\Api\InformationInterface::class) { 24 | return $data; 25 | } else { 26 | return $this->convertValue($data, $dataType); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Model/Settings.php: -------------------------------------------------------------------------------- 1 | _init(\Vuefront\Vuefront\Model\ResourceModel\Settings::class); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Plugin/CorsRequestMatchPlugin.php: -------------------------------------------------------------------------------- 1 | request = $request; 19 | $this->routeFactory = $routeFactory; 20 | } 21 | 22 | public function aroundMatch( 23 | Router $subject, 24 | callable $proceed, 25 | Request $request 26 | ) { 27 | try { 28 | $returnValue = $proceed($request); 29 | } catch (\Magento\Framework\Webapi\Exception $e) { 30 | $requestHttpMethod = $this->request->getHttpMethod(); 31 | 32 | $position = strpos($this->request->getRequestUri(), 'vuefront'); 33 | if ($requestHttpMethod === 'OPTIONS' && $position > 0) { 34 | return $this->createRoute(); 35 | } else { 36 | throw $e; 37 | } 38 | } 39 | return $returnValue; 40 | } 41 | 42 | protected function createRoute() 43 | { 44 | $route = $this->routeFactory->createRoute( 45 | \Magento\Webapi\Controller\Rest\Router\Route::class, 46 | '/V1/vuefront/cors' 47 | ); 48 | 49 | $route->setServiceClass(\Vuefront\Vuefront\Api\GraphqlInterface::class) 50 | ->setServiceMethod('cors') 51 | ->setSecure(false) 52 | ->setAclResources(['anonymous']) 53 | ->setParameters([]); 54 | 55 | return $route; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /Plugin/CorsRequestOptionsPlugin.php: -------------------------------------------------------------------------------- 1 | isGet() && !$subject->isPost() 14 | && !$subject->isPut() && !$subject->isDelete() 15 | && !$subject->isOptions()) { 16 | throw new InputException(__('Request method is invalid.')); 17 | } 18 | return $subject->getMethod(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vuefront/module-vuefront", 3 | "description": "Vuefront api for magento2", 4 | "type": "magento2-module", 5 | "version": "0.3.1", 6 | "canonical": false, 7 | "require": { 8 | "webonyx/graphql-php": ">=0.12.6", 9 | "vuefront/module-blog" : ">=0.1.2", 10 | "vuefront/module-brands": ">=0.1.2", 11 | "ext-json": "*" 12 | }, 13 | "license": [ 14 | "OSL-3.0", 15 | "AFL-3.0" 16 | ], 17 | "autoload": { 18 | "files": [ 19 | "registration.php" 20 | ], 21 | "psr-4": { 22 | "Vuefront\\Vuefront\\": "" 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /etc/acl.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /etc/adminhtml/menu.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 8 | 11 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /etc/adminhtml/routes.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /etc/adminhtml/system.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 |
9 | separator-top 10 | 11 | vuefront 12 | Vuefront_Vuefront::vuefront_config 13 | 15 | 16 | 18 | 19 | Magento\Config\Model\Config\Source\Yesno 20 | 21 | 22 |
23 |
24 |
25 | -------------------------------------------------------------------------------- /etc/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 1 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /etc/db_schema.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 |
23 | -------------------------------------------------------------------------------- /etc/di.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /etc/email_templates.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 |