Skip to content

Instantly share code, notes, and snippets.

@betobaz
Created July 15, 2014 16:08
Show Gist options
  • Save betobaz/f2e706fd50054a43ed98 to your computer and use it in GitHub Desktop.
Save betobaz/f2e706fd50054a43ed98 to your computer and use it in GitHub Desktop.
SugarCRM::SugarQuery:: Join with custom module
<?php
$sugarQuery = new SugarQuery();
$sugarQuery->select(array('id', 'name', 'precio'));
$precioBean = BeanFactory::newBean('MXC06_Precio');
$sugarQuery->from($precioBean);
$sugarQuery->join('mxc06_precio_accounts');
$sugarQuery->join('mxc06_precio_producttemplates');
$sugarQuery->where()
->equals('mxc06_precio_accountsaccounts_ida', $pedido->cmx03_pedidos_accountsaccounts_ida)
->equals('mxc06_precio_producttemplatesproducttemplates_ida', $bean->cmx03_detallespedido_producttemplatesproducttemplates_ida);
$GLOBALS['log']->debug("QuoteLogicHook::getPrecio query:" . print_r($sugarQuery->compileSql(), true) );
$result = $sugarQuery->execute();
@rszczypka
Copy link

Hi, I'm curious about this. Where do you keep this file and how do you use it?
I need to do a similar thing with custom modules.

@betobaz
Copy link
Author

betobaz commented Dec 4, 2015

Hi rszczypka,

what do you exactly need to do?

This is a little snippet, you can use it on jobs, logic hooks, apis.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment