diff --git a/Model/Resolver/BrandConfigResolver.php b/Model/Resolver/BrandConfigResolver.php index 42612c4..724719c 100644 --- a/Model/Resolver/BrandConfigResolver.php +++ b/Model/Resolver/BrandConfigResolver.php @@ -26,8 +26,8 @@ use Magento\Framework\GraphQl\Exception\GraphQlInputException; use Magento\Framework\GraphQl\Query\ResolverInterface; use Magento\Framework\GraphQl\Schema\Type\ResolveInfo; +use Mageplaza\Shopbybrand\Api\BrandRepositoryInterface; use Mageplaza\Shopbybrand\Helper\Data; -use Mageplaza\ShopbybrandGraphQl\Model\Resolver\Brands\BrandConfigDataProvider; /** * Class BrandConfigResolver @@ -35,27 +35,28 @@ */ class BrandConfigResolver implements ResolverInterface { - /** - * @var BrandConfigDataProvider - */ - protected $brandConfigDataProvider; /** * @var Data */ protected $helperData; + /** + * @var BrandRepositoryInterface + */ + protected $brandRepository; + /** * BrandConfigResolver constructor. * * @param Data $helperData - * @param BrandConfigDataProvider $brandConfigDataProvider + * @param BrandRepositoryInterface $brandRepository */ public function __construct( Data $helperData, - BrandConfigDataProvider $brandConfigDataProvider + BrandRepositoryInterface $brandRepository ) { - $this->helperData = $helperData; - $this->brandConfigDataProvider = $brandConfigDataProvider; + $this->helperData = $helperData; + $this->brandRepository = $brandRepository; } /** @@ -76,6 +77,14 @@ public function resolve( $storeId = $args['storeId']; } - return $this->brandConfigDataProvider->getBrandConfigData($storeId); + $config = $this->brandRepository->getBrandConfigs($storeId); + + return [ + 'general' => $config->getGeneral(), + 'brands_page_settings' => $config->getBrandsPageSettings(), + 'brand_info' => $config->getBrandInfo(), + 'sidebar' => $config->getSidebar(), + 'seo' => $config->getSeo() + ]; } } diff --git a/Model/Resolver/Brands/BrandConfigDataProvider.php b/Model/Resolver/Brands/BrandConfigDataProvider.php deleted file mode 100644 index 2435876..0000000 --- a/Model/Resolver/Brands/BrandConfigDataProvider.php +++ /dev/null @@ -1,77 +0,0 @@ -brandRepository = $brandRepository; - } - - /** - * Get brand config data - * - * @param string|null $storeId - * @return array - */ - public function getBrandConfigData($storeId): array - { - $brandConfigs = $this->brandRepository->getBrandConfigs($storeId); - $brandConfigData = [ - 'brand_list_name' => $brandConfigs->getBrandListName(), - 'brandlist_style' => $brandConfigs->getBrandlistStyle(), - 'display_option' => $brandConfigs->getDisplayOption(), - 'brand_list_logo_width' => $brandConfigs->getBrandListLogoWidth(), - 'brand_list_logo_height' => $brandConfigs->getBrandListLogoHeight(), - 'color' => $brandConfigs->getColor(), - 'show_description' => $brandConfigs->getShowDescription(), - 'show_product_qty' => $brandConfigs->getShowProductQty(), - 'custom_css' => $brandConfigs->getCustomCss(), - 'show_brand_info_in_listing' => $brandConfigs->getShowBrandInfoInListing(), - 'show_brand_info' => $brandConfigs->getShowBrandInfo(), - 'show_brand_info_in_admin' => $brandConfigs->getShowBrandInfoInAdmin(), - 'logo_width_on_product_page' => $brandConfigs->getLogoWidthOnProductPage(), - 'logo_height_on_product_page' => $brandConfigs->getLogoHeightOnProductPage() - ]; - - return $brandConfigData; - } -} diff --git a/Plugin/DataProvider/Product/Aggregations.php b/Plugin/DataProvider/Product/Aggregations.php new file mode 100644 index 0000000..ff54425 --- /dev/null +++ b/Plugin/DataProvider/Product/Aggregations.php @@ -0,0 +1,68 @@ +helperData = $helperData; + } + + /** + * @param Attribute $subject + * @param array $results + * + * @return mixed + */ + public function afterBuild(Attribute $subject, $results) + { + if ($this->helperData->isEnabled() && $this->helperData->getAttributeCode() && $results) { + foreach ($results as $bucketName => &$data) { + if ($this->helperData->getAttributeCode() === $data['attribute_code']) { + $results[$bucketName]['is_mp_brand'] = true; + } + } + } + + return $results; + } +} diff --git a/composer.json b/composer.json index aa216d9..52bc91b 100644 --- a/composer.json +++ b/composer.json @@ -1,23 +1,23 @@ -{ - "name": "mageplaza/module-shop-by-brand-graphql", - "description": "Magento 2 Shop By Brand GraphQl Extension", - "type": "magento2-module", - "version": "1.0.3", - "license": "proprietary", - "authors": [ - { - "name": "Mageplaza", - "email": "support@mageplaza.com", - "homepage": "https://www.mageplaza.com", - "role": "Technical Support" - } - ], - "autoload": { - "files": [ - "registration.php" - ], - "psr-4": { - "Mageplaza\\ShopbybrandGraphQl\\": "" - } - } -} +{ + "name": "mageplaza/module-shop-by-brand-graphql", + "description": "Magento 2 Shop By Brand GraphQl Extension", + "type": "magento2-module", + "version": "1.0.4", + "license": "proprietary", + "authors": [ + { + "name": "Mageplaza", + "email": "support@mageplaza.com", + "homepage": "https://www.mageplaza.com", + "role": "Technical Support" + } + ], + "autoload": { + "files": [ + "registration.php" + ], + "psr-4": { + "Mageplaza\\ShopbybrandGraphQl\\": "" + } + } +} diff --git a/etc/di.xml b/etc/di.xml index 41e3d48..1708a0e 100644 --- a/etc/di.xml +++ b/etc/di.xml @@ -29,4 +29,7 @@ - \ No newline at end of file + + + + diff --git a/etc/schema.graphqls b/etc/schema.graphqls index 0670d40..1de97dc 100644 --- a/etc/schema.graphqls +++ b/etc/schema.graphqls @@ -76,19 +76,86 @@ interface ProductInterface { mpbrand: MageplazaBrands @doc(description: "Mageplaza Shopbybrand Attribute data") @resolver(class: "Mageplaza\\ShopbybrandGraphQl\\Model\\Resolver\\Product\\Brand") } +type Aggregation { + is_mp_brand: Boolean @doc(description: "Mageplaza Shopbybrand Aggregation") +} + type BrandConfig @doc(description: "The type contains information about a brand config") { - brand_list_name : String @doc(description: "The Brand List Name assigned to the store") - brandlist_style : Int @doc(description: "Style on Brand List Page. List: 0, Alphabet: 1") - display_option : Int @doc(description: "The display option on Brand List Page. Logo Only: 0, Logo and Label: 1, Label Only: 2") - brand_list_logo_width : Int @doc(description: "Logo Width on Brand List Page") - brand_list_logo_height : Int @doc(description: "Logo Height on Brand List Page") - color : String @doc(description: "Color on Brand List Page") - show_description : Boolean @doc(description: "Show Brand description on Brand List Page") - show_product_qty : Boolean @doc(description: "Show product qty on Brand List Page") - custom_css : String @doc(description: "Custom css on Brand List Page") - show_brand_info_in_listing : String @doc(description: "Show brand info on list product page") - show_brand_info : String @doc(description: "Show brand info on product page") - show_brand_info_in_admin : String @doc(description: "Show brand info on product grid at admin") - logo_width_on_product_page : Int @doc(description: "logo Width on product page") - logo_height_on_product_page : Int @doc(description: "logo Height on product page") + general: BrandGeneralConfig @doc(description: "Get General Config") + brands_page_settings: BrandsPageSettingsConfig @doc(description: "Get All Brands Page Settings Config") + brand_info: BrandInformationConfig @doc(description: "Get Brand Information Config") + sidebar: SidebarConfig @doc(description: "Get Sidebar Config") + seo: SeoConfig @doc(description: "Get SEO Config") +} + +type BrandGeneralConfig { + is_enabled: Int @doc(description: "Enabled") + brand_attribute: String @doc(description: "Brand Attribute") + brand_route: String @doc(description: "Brand Route") + brand_link_title: String @doc(description: "Brand Link Title") + show_brand_link_in: String @doc(description: "Show brand link in") + show_brand_in_category_menu: Int @doc(description: "Show Brands in Category Menu") + what_to_show: String @doc(description: "What to show") + brand_menu_grid_layout: String @doc(description: "Brand Menu Grid Layout") + maximum_brands_to_show: String @doc(description: "Maximum brands to show") + show_brands_without_products_on_menu: Int @doc(description: "Show brands without products on menu") + show_brand_info_on_product_listing_page: String @doc(description: "Show Brand Info on Product Listing Page") + show_brand_info_in_product_page: String @doc(description: "Show Brand Info in Product Page") + show_brand_info_in_product_admin_grid: String @doc(description: "Show Brand Info in Product Admin Grid") + brand_logo_width_in_product_page: String @doc(description: "Brand Logo Width in Product Page") + brand_logo_height_in_product_page: String @doc(description: "Brand Logo Height in Product Page") +} + +type BrandsPageSettingsConfig { + brand_list_name: String @doc(description: "Brand List Name") + style_of_brand_list_page: Int @doc(description: "Style of Brand List Page") + display_option: Int @doc(description: "Display Option") + brand_logo_width: String @doc(description: "Brand Logo Width") + brand_logo_height: String @doc(description: "Brand Logo Height") + style_color: String @doc(description: "Style Color") + show_brand_short_description: Int @doc(description: "Show Brand Short Description") + show_brands_without_products: Int @doc(description: "Show brands without products") + show_brand_product_quantity: Int @doc(description: "Show Brand Product Quantity") + show_brand_quick_view_popup: Int @doc(description: "Show Brand Quick View Popup") + custom_css: String @doc(description: "Custom CSS") + show_brand_categories_filter: Int @doc(description: "Show Brand Categories Filter") + show_brand_alphabet_filter: Int @doc(description: "Show Brand Alphabet Filter") + brand_filter_alphabet: String @doc(description: "Brand Alphabet") + brand_filter_character_set: String @doc(description: "Character Set") + show_brand_search_block: Int @doc(description: "Show Search Block") + brand_search_min_chars: String @doc(description: "Min chars") + brand_search_number_of_search_result: String @doc(description: "Number of Search Result") + brand_search_show_thumbnail_image: Int @doc(description: "Show Thumbnail Image") + show_featured_brands: Int @doc(description: "Show Featured Brands") + display_featured_brands_style: Int @doc(description: "Display Featured Brands Style") + featured_brand_title: String @doc(description: "Featured Brands Title") + display_information_featured_brands: Int @doc(description: "Display Information") + show_related_products: Int @doc(description: "Show Related Products") + brand_related_title: String @doc(description: "Brand Related Title") + brand_related_limit: String @doc(description: "Brand Related Limit") +} + +type BrandInformationConfig { + default_image: String @doc(description: "Default Image") + default_block: String @doc(description: "Default Block") + show_brand_image_on_brand_page: Int @doc(description: "Show Brand Image On Brand Page") + show_brand_description_on_brand_page: Int @doc(description: "Show Brand Description On Brand Page") + show_brand_static_block_on_brand_page: Int @doc(description: "Show Brand Static Block On Brand Page") +} + +type SidebarConfig { + show_featured_brands: Int @doc(description: "Show Featured Brands") + featured_brand_title: String @doc(description: "Featured Brands Title") + featured_brand_show_title: Int @doc(description: "Featured Brand Show Title") + show_brand_thumbnail: Int @doc(description: "Show Brand Thumbnail") + brand_thumbnail_title: String @doc(description: "Brand Thumbnail Title") + brands_qty_limit: String @doc(description: "Brand's Qty Limit") + show_category_brand: Int @doc(description: "Show Category Brand") + category_brand_title: String @doc(description: "Category Brand Title") + category_qty_limit: String @doc(description: "Category's Qty Limit") + show_brand_category_quantity: Int @doc(description: "Show Brand Category Quantity") +} + +type SeoConfig { + add_noindex_to_pagination_pages: Int @doc(description: "Add Noindex to Pagination Pages") }