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/old/app/code/Soon/Social/Helper/Catalog/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/old/app/code/Soon/Social/Helper/Catalog/Product.php
<?php
/**
 * This file is part of Soon_Social for Magento.
 *
 * @license All rights reserved
 * @author Antoine Kociuba <[email protected]> <@antoinekociuba>
 * @category Soon
 * @package Soon_Social
 * @copyright Copyright (c) 2015 Agence Soon (http://www.agence-soon.fr)
 */

namespace Soon\Social\Helper\Catalog;

use Magento\Framework\App\Helper\AbstractHelper;
use Magento\Framework\App\Helper\Context;
use Magento\Framework\Registry;
use Magento\Catalog\Helper\Output;
use Magento\Catalog\Helper\Image;
use Magento\Framework\Pricing\PriceCurrencyInterface;
use Magento\Framework\Escaper;
use Magento\Store\Model\StoreManagerInterface;

/**
 * Catalog_Product Helper
 * @package Soon_Social
 */
class Product extends AbstractHelper
{

// Agence Soon Tag NEW_CONST

    /**
     * @var \Magento\Catalog\Model\Product
     */
    protected $_product;

    /**
     * @var \Magento\Framework\Registry
     */
    protected $_registry;

    /**
     * @var \Magento\Catalog\Helper\Output
     */
    protected $_outputHelper;

    /**
     * @var \Magento\Catalog\Helper\Image
     */
    protected $_imageHelper;

    /**
     * @var \Magento\Framework\Pricing\PriceCurrencyInterface
     */
    protected $_priceCurrency;

    /**
     * @var \Magento\Framework\App\Config\ScopeConfigInterface
     */
    protected $_scopeConfig;

    /**
     * @var \Magento\Framework\Escaper
     */
    protected $_escaper;

    /**
     * @var \Magento\Store\Model\StoreManagerInterface
     */
    protected $_storeManager;

    /**
     * Product constructor.
     * @param Context $context
     * @param Registry $registry
     * @param Output $outputHelper
     * @param Image $imageHelper
     * @param PriceCurrencyInterface $priceCurrency
     * @param Escaper $escaper
     * @param StoreManagerInterface $storeManager
     */
    public function __construct(
        Context $context,
        Registry $registry,
        Output $outputHelper,
        Image $imageHelper,
        PriceCurrencyInterface $priceCurrency,
        Escaper $escaper,
        StoreManagerInterface $storeManager
    ) {
        parent::__construct($context);
        $this->_registry = $registry;
        $this->_outputHelper = $outputHelper;
        $this->_imageHelper = $imageHelper;
        $this->_priceCurrency = $priceCurrency;
        $this->_scopeConfig = $context->getScopeConfig();
        $this->_escaper = $escaper;
        $this->_storeManager = $storeManager;
    }

    /**
     * @return \Magento\Catalog\Model\Product|mixed
     * @throws \Exception
     */
    public function getProduct()
    {
        /**
         * try to grab product from registry
         */
        if (is_null($this->_product)) {
            if ($product = $this->_registry->registry('current_product')) {
                $this->_product = $product;
            }
        }

        if (is_null($this->_product) || !$this->_product->getId()) {
            throw new \Exception('No valid product currently defined.');
        }
        return $this->_product;
    }

    /**
     *  Get current product attribute
     *
     * @param $attributeName
     * @param bool $urlEncodeFlag
     * @return string
     * @throws \Exception
     */
    public function getProductAttribute($attributeName, $urlEncodeFlag = false)
    {
        $product = $this->getProduct();

        switch ($attributeName) {
            case 'description':
            case 'short_description':
                $value = strip_tags($this->_outputHelper->productAttribute($product,
                    nl2br($product->getData($attributeName)), $attributeName));
                break;
            case 'image':
                $value = $this->_imageHelper->init($this->_product, 'product_base_image')->resize(800)->getUrl();
                break;
            case 'url':
                $value = $product->getUrlInStore();
                break;
            default:
                $value = $this->_escaper->escapeHtml(
                    $this->_outputHelper->productAttribute($product, $product->getData($attributeName),
                        $attributeName)
                );
                break;
        }

        /**
         * Escape quote in order to not break meta values (double quoted)
         */
        $value = $this->_escaper->escapeQuote($value);

        /**
         * Url encode if specified
         */
        if ($urlEncodeFlag) {
            $value = rawurlencode($value);
        }

        return trim($value);
    }

    /**
     * Get current currency code
     *
     * @return string
     */
    public function getCurrentCurrencyCode()
    {
        /** @var \Magento\Directory\Model\Currency $currency */
        $currency = $this->_priceCurrency->getCurrency();
        return $currency->getCurrencyCode();
    }

    /**
     * @return bool
     */
    protected function getCurrentCurrencyPrice()
    {
        if (!$this->_product->getFinalPrice()) {
            return false;
        }
        return $this->_priceCurrency->convertAndFormat($this->_product->getFinalPrice(), false);
    }

    /**
     * @param string $path
     * @return string
     */
    protected function _getConfig($path)
    {
        return $this->_scopeConfig->getValue(
            $path,
            \Magento\Store\Model\ScopeInterface::SCOPE_STORE
        );
    }
// Agence Soon Tag NEW_METHOD

}

Spamworldpro Mini