YetiForceCompany/YetiForceCRM

View on GitHub
modules/IStorages/relations/GetManyToMany.php

Summary

Maintainability
A
1 hr
Test Coverage
F
0%
<?php
/**
 * Main file that includes basic operations on relations.
 *
 * @package   Relation
 *
 * @copyright YetiForce S.A.
 * @license   YetiForce Public License 6.5 (licenses/LicenseEN.txt or yetiforce.com)
 * @author    Radosław Skrzypczak <r.skrzypczak@yetiforce.com>
 */

/**
 * IStorages_GetManyToMany_Relation class.
 */
class IStorages_GetManyToMany_Relation extends Vtiger_GetManyToMany_Relation
{
    /** {@inheritdoc} */
    public function getQuery()
    {
        $relatedModuleName = $this->relationModel->getRelationModuleName();
        if ('Products' === $relatedModuleName) {
            $parentModuleName = $this->relationModel->getParentModuleModel()->getName();
            $referenceInfo = \Vtiger_Relation_Model::getReferenceTableInfo($relatedModuleName, $parentModuleName);
            $this->relationModel->getQueryGenerator()->setCustomColumn(['qtyproductinstock' => $referenceInfo['table'] . '.qtyinstock']);
        }
        parent::getQuery();
    }
}