11<?php
22/**
3- * Copyright © Magento, Inc. All rights reserved.
4- * See COPYING.txt for license details .
3+ * Copyright 2014 Adobe
4+ * All Rights Reserved .
55 */
66declare (strict_types=1 );
77
1212use Magento \Framework \App \ObjectManager ;
1313use Magento \LoginAsCustomerApi \Api \ConfigInterface ;
1414use Magento \LoginAsCustomerApi \Api \GetLoggedAsCustomerAdminIdInterface ;
15+ use Magento \Framework \App \Config \ScopeConfigInterface ;
16+ use Magento \Store \Model \StoreManagerInterface ;
1517
1618/**
1719 * View model to get extension configuration in the template
@@ -33,20 +35,36 @@ class Configuration implements \Magento\Framework\View\Element\Block\ArgumentInt
3335 */
3436 private $ getLoggedAsCustomerAdminId ;
3537
38+ /**
39+ * @var ScopeConfigInterface
40+ */
41+ private $ scopeConfig ;
42+
43+ /**
44+ * @var StoreManagerInterface
45+ */
46+ private $ storeManager ;
47+
3648 /**
3749 * @param ConfigInterface $config
3850 * @param HttpContext $httpContext
51+ * @param ScopeConfigInterface $scopeConfig
52+ * @param StoreManagerInterface $storeManager
3953 * @param GetLoggedAsCustomerAdminIdInterface $getLoggedAsCustomerAdminId
4054 */
4155 public function __construct (
4256 ConfigInterface $ config ,
4357 HttpContext $ httpContext ,
58+ ScopeConfigInterface $ scopeConfig ,
59+ StoreManagerInterface $ storeManager ,
4460 ?GetLoggedAsCustomerAdminIdInterface $ getLoggedAsCustomerAdminId = null
4561 ) {
4662 $ this ->config = $ config ;
4763 $ this ->httpContext = $ httpContext ;
4864 $ this ->getLoggedAsCustomerAdminId = $ getLoggedAsCustomerAdminId
4965 ?? ObjectManager::getInstance ()->get (GetLoggedAsCustomerAdminIdInterface::class);
66+ $ this ->scopeConfig = $ scopeConfig ;
67+ $ this ->storeManager = $ storeManager ;
5068 }
5169
5270 /**
@@ -68,4 +86,19 @@ private function isLoggedIn(): bool
6886 {
6987 return (bool )$ this ->httpContext ->getValue (Context::CONTEXT_AUTH );
7088 }
89+
90+ /**
91+ * Is B2b enabled
92+ *
93+ * @return bool
94+ * @throws \Magento\Framework\Exception\NoSuchEntityException
95+ */
96+ public function isB2bEnabled (): bool
97+ {
98+ return (bool )$ this ->scopeConfig ->getValue (
99+ "btob/website_configuration/company_active " ,
100+ \Magento \Store \Model \ScopeInterface::SCOPE_WEBSITE ,
101+ $ this ->storeManager ->getStore ()->getWebsiteId ()
102+ );
103+ }
71104}
0 commit comments