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/wyomind/msicustomattributes/Observer/MsiStockManagement/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/old/vendor/wyomind/msicustomattributes/Observer/MsiStockManagement/GridPrepare.php
<?php

/**
 * Copyright © 2020 Wyomind. All rights reserved.
 * See LICENSE.txt for license details.
 */
/**
 * Copyright © 2020 Wyomind. All rights reserved.
 * See LICENSE.txt for license details.
 */
namespace Wyomind\MsiCustomAttributes\Observer\MsiStockManagement;

use Magento\Framework\Event\Observer;
use Wyomind\MsiCustomAttributes\Model\ResourceModel\CustomAttributeValue;
use Wyomind\MsiCustomAttributes\Model\ResourceModel\CustomAttribute;
/**
 * Class GridPrepare
 * @package Wyomind\MsiCustomAttributes\Observer\MsiStockManagement
 */
class GridPrepare implements \Magento\Framework\Event\ObserverInterface
{
    public $repository;
    public function __construct(\Wyomind\MsiCustomAttributes\Helper\Delegate $wyomind)
    {
        $wyomind->constructor($this, $wyomind, __CLASS__);
    }
    /**
     * @param Observer $observer
     */
    public function execute(Observer $observer)
    {
        $collection = $observer->getEvent()->getCollection();
        $attributes = $this->repository->list();
        $customAttributeValue = $collection->getTable(CustomAttributeValue::MSI_CUSTOM_ATTRIBUTE_VALUE);
        $customAttribute = $collection->getTable(CustomAttribute::MSI_CUSTOM_ATTRIBUTE);
        foreach ($attributes as $attribute) {
            $collection->getSelect()->joinLeft(['msi_default_' . $attribute->getCode() => $customAttribute], "msi_default_" . $attribute->getCode() . ".attribute_id= " . $attribute->getAttributeId(), []);
            $collection->getSelect()->joinLeft(['msi_' . $attribute->getCode() => $customAttributeValue], "msi_" . $attribute->getCode() . ".source_code= main_table.source_code AND msi_" . $attribute->getCode() . ".sku=`main_table`.`sku` AND msi_" . $attribute->getCode() . ".attribute_id=msi_default_" . $attribute->getCode() . ".attribute_id", [$attribute->getCode() => "IFNULL(msi_" . $attribute->getCode() . ".value,msi_default_" . $attribute->getCode() . ".default)"]);
        }
    }
}

Spamworldpro Mini