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/vendor/mageworx/module-seobreadcrumbs/Plugin/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/old/vendor/mageworx/module-seobreadcrumbs/Plugin/ExtendCategoryCollection.php
<?php
/**
 * Copyright © 2016 MageWorx. All rights reserved.
 * See LICENSE.txt for license details.
 */

namespace MageWorx\SeoBreadcrumbs\Plugin;

class ExtendCategoryCollection
{
    /**
     *
     * @var \MageWorx\SeoBreadcrumbs\Helper\Data
     */
    protected $helperData;

    /**
     * Instance of category collection.
     *
     * @var \Magento\Catalog\Model\ResourceModel\Category\Collection
     */
    protected $categoryCollection;

    /**
     * Request object
     *
     * @var \Magento\Framework\App\RequestInterface
     */
    protected $request;

    /**
     * ExtendCategoryCollection constructor.
     * @param \MageWorx\SeoBreadcrumbs\Helper\Data $helperData
     */
    public function __construct(
        \MageWorx\SeoBreadcrumbs\Helper\Data $helperData,
        \Magento\Framework\App\RequestInterface $request
    ) {
        $this->helperData = $helperData;
        $this->request = $request;
    }


    /**
     * Add additional attributes to product category collection
     *
     * @param \Magento\Catalog\Model\Product $product
     * @param \Magento\Catalog\Model\ResourceModel\Category\Collection $result
     * @return \Magento\Catalog\Model\ResourceModel\Category\Collection
     */
    public function afterGetCategoryCollection($product, $result)
    {
        if (!$this->helperData->isSeoBreadcrumbsEnabled()) {
            return $result;
        }

        if ($this->request->getFullActionName() != 'catalog_product_view') {
            return $result;
        }

        if (!($result instanceof \Magento\Catalog\Model\ResourceModel\Category\Collection)) {
            return $result;
        }

        if (!is_object($product)) {
            return $result;
        }

        if ($product->getId() != $this->request->getParam('id')) {
            return $result;
        }

        if ($this->categoryCollection === null) {
            $result->addAttributeToSelect(['name', 'url_key', 'is_active']);
            if ($this->helperData->isUseCategoryBreadcrumbsPriority()) {
                $result->addAttributeToSelect(
                    \MageWorx\SeoBreadcrumbs\Helper\Data::BREADCRUMBS_PRIORITY_CODE,
                    'left'
                );
            }
            $this->categoryCollection = $result;
        }

        return $result;
    }
}

Spamworldpro Mini