Example #1
0
 /**
  * Join table sales_order_address to select for billing and shipping order addresses.
  * Create correlation map
  *
  * @return $this
  */
 protected function _addAddressFields()
 {
     $billingAliasName = 'billing_o_a';
     $shippingAliasName = 'shipping_o_a';
     $joinTable = $this->getTable('sales_order_address');
     $this->addFilterToMap('billing_firstname', $billingAliasName . '.firstname')->addFilterToMap('billing_lastname', $billingAliasName . '.lastname')->addFilterToMap('billing_telephone', $billingAliasName . '.telephone')->addFilterToMap('billing_postcode', $billingAliasName . '.postcode')->addFilterToMap('shipping_firstname', $shippingAliasName . '.firstname')->addFilterToMap('shipping_lastname', $shippingAliasName . '.lastname')->addFilterToMap('shipping_telephone', $shippingAliasName . '.telephone')->addFilterToMap('shipping_postcode', $shippingAliasName . '.postcode');
     $this->getSelect()->joinLeft([$billingAliasName => $joinTable], "(main_table.entity_id = {$billingAliasName}.parent_id" . " AND {$billingAliasName}.address_type = 'billing')", [$billingAliasName . '.firstname', $billingAliasName . '.lastname', $billingAliasName . '.telephone', $billingAliasName . '.postcode'])->joinLeft([$shippingAliasName => $joinTable], "(main_table.entity_id = {$shippingAliasName}.parent_id" . " AND {$shippingAliasName}.address_type = 'shipping')", [$shippingAliasName . '.firstname', $shippingAliasName . '.lastname', $shippingAliasName . '.telephone', $shippingAliasName . '.postcode']);
     $this->_coreResourceHelper->prepareColumnsList($this->getSelect());
     return $this;
 }
Example #2
0
 /**
  * Join product and type data
  *
  * @return $this
  */
 protected function _joinTables()
 {
     $entityType = $this->_eavConfig->getEntityType('catalog_product');
     $attribute = $this->_eavConfig->getAttribute($entityType->getEntityTypeId(), 'name');
     $joinConditionDefault = sprintf("p_d.attribute_id=%d AND p_d.store_id='0' AND main_table.product_id=p_d.entity_id", $attribute->getAttributeId());
     $joinCondition = sprintf("p.attribute_id=%d AND p.store_id=main_table.store_id AND main_table.product_id=p.entity_id", $attribute->getAttributeId());
     $this->getSelect()->joinLeft(array('p_d' => $attribute->getBackend()->getTable()), $joinConditionDefault, array());
     $this->getSelect()->joinLeft(array('p' => $attribute->getBackend()->getTable()), $joinCondition, array('name' => $this->getConnection()->getIfNullSql('p.value', 'p_d.value')));
     $this->getSelect()->joinLeft(array('types' => $this->getTable('googleshopping_types')), 'main_table.type_id=types.type_id');
     $this->_resourceHelper->prepareColumnsList($this->getSelect());
     // avoid column name collision
     return $this;
 }
 public function testPrepareColumnsList()
 {
     $columns = $this->_model->prepareColumnsList($this->_select);
     $this->assertContains('STORE_ID', array_keys($columns));
 }