Spamworldpro Mini Shell
Spamworldpro


Server : Apache
System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64
User : corals ( 1002)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/corals/Ecombricks/InventoryInventorySales/Api/Data/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/Ecombricks/InventoryInventorySales/Api/Data/WebsiteSalesChannelInterfaceFactory.php
<?php
/**
 * Copyright © eComBricks. All rights reserved.
 * See LICENSE.txt for license details.
 */
namespace Ecombricks\InventoryInventorySales\Api\Data;

/**
 * Website sales channel interface factory
 */
class WebsiteSalesChannelInterfaceFactory
{
    
    /**
     * Object Manager
     *
     * @var \Magento\Framework\ObjectManagerInterface
     */
    protected $objectManager;
    
    /**
     * Website repository
     * 
     * @var \Magento\Store\Api\WebsiteRepositoryInterface
     */
    protected $websiteRepository;
    
    /**
     * Instance name
     * 
     * @var string
     */
    protected $instanceName;
    
    /**
     * Constructor
     * 
     * @param \Magento\Framework\ObjectManagerInterface $objectManager
     * @param \Magento\Store\Api\WebsiteRepositoryInterface $websiteRepository
     * @param string $instanceName
     * @return void
     */
    public function __construct(
        \Magento\Framework\ObjectManagerInterface $objectManager,
        \Magento\Store\Api\WebsiteRepositoryInterface $websiteRepository,
        $instanceName = \Magento\InventorySalesApi\Api\Data\SalesChannelInterface::class
    )
    {
        $this->objectManager = $objectManager;
        $this->websiteRepository = $websiteRepository;
        $this->instanceName = $instanceName;
    }
    
    /**
     * Get website code
     * 
     * @param int $websiteId
     * @return string
     */
    protected function getWebsiteCode($websiteId)
    {
        return $this->websiteRepository->getById((int) $websiteId)->getCode();
    }
    
    /**
     * Create
     *
     * @param int $websiteId
     * @return \Magento\InventorySalesApi\Api\Data\SalesChannelInterface
     */
    public function create($websiteId)
    {
        return $this->objectManager->create($this->instanceName, [
            'data' => [
                'type' => \Magento\InventorySalesApi\Api\Data\SalesChannelInterface::TYPE_WEBSITE,
                'code' => $this->getWebsiteCode($websiteId),
            ]
        ]);
    }
    
}

Spamworldpro Mini