/** * Gets an item for displaying (as opposed to saving, which requires a JTable object) * using the query from the model and the tbl's unique identifier * * @return database->loadObject() record */ public function getItem($pk = null, $refresh = false, $emptyState = true) { parent::getItem($emptyState); // adding this in the model so we don't have to have if statemnets all over the views and controllers' if (version_compare(JVERSION, '1.6.0', 'ge')) { if (!empty($this->_item->extension_id)) { $this->_item->id = $this->_item->extension_id; } } return $this->_item; }
public function getItem($pk = null, $refresh = false, $emptyState = true) { if ($item = parent::getItem($pk)) { // Convert the params field to an array. if (version_compare(JVERSION, '1.6.0', 'ge')) { $formdata = new JRegistry(); $formdata->loadString($item->params); $item->data = $formdata->toArray('data'); } } return $item; }
/** * Get the item with the related attributes (if $getEav is true) * @param boolean $emptyState * @param boolean $getEav */ public function getItem($refresh = true, $getEav = true, $emptyState = true) { $this->_getEav = $getEav; $this->_getEavOptions = array(); return parent::getItem(null, $refresh, $emptyState); }
public function getItem($pk = null, $refresh = false, $emptyState = true) { Citruscart::load('CitruscartHelperSubscription', 'helpers.subscription'); if ($item = parent::getItem($pk, $refresh, $emptyState)) { $item->link = 'index.php?option=com_citruscart&view=subscriptions&task=edit&id=' . $item->subscription_id; $item->link_view = 'index.php?option=com_citruscart&view=subscriptions&task=view&id=' . $item->subscription_id; $item->history = CitruscartHelperSubscription::getHistory($item->subscription_id); Citruscart::load('CitruscartQuery', 'library.query'); $q = new CitruscartQuery(); $q->select('order_hash'); $q->from('#__citruscart_orders'); $q->where('order_id = ' . $item->order_id); $db = JFactory::getDbo(); $db->setQuery($q); $item->order_hash = $db->loadResult(); } JFactory::getApplication()->triggerEvent('onPrepare' . $this->getTable()->get('_suffix'), array(&$item)); return $item; }
public function getItem($pk = null, $refresh = false, $emptyState = true) { if (empty($this->_item)) { Citruscart::load('CitruscartHelperBase', 'helpers._base'); JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_citruscart/models'); $amigos = CitruscartHelperBase::getInstance('Amigos'); $currency_helper = CitruscartHelperBase::getInstance('Currency'); if ($item = parent::getItem($pk, $refresh, $emptyState)) { // get the orderinfo $item->orderinfo = JTable::getInstance('OrderInfo', 'CitruscartTable'); $item->orderinfo->load(array('order_id' => $item->order_id)); //retrieve the order's items $model = JModelLegacy::getInstance('OrderItems', 'CitruscartModel'); $model->setState('filter_orderid', $item->order_id); $model->setState('order', 'tbl.orderitem_name'); $model->setState('direction', 'ASC'); $item->orderitems = $model->getList($refresh); foreach ($item->orderitems as $orderitem) { $model = JModelLegacy::getInstance('OrderItemAttributes', 'CitruscartModel'); $model->setState('filter_orderitemid', $orderitem->orderitem_id); $attributes = $model->getList(); $attributes_names = array(); $attributes_codes = array(); foreach ($attributes as $attribute) { // store a csv of the attrib names $attributes_names[] = JText::_($attribute->orderitemattribute_name); if ($attribute->orderitemattribute_code) { $attributes_codes[] = JText::_($attribute->orderitemattribute_code); } } $orderitem->attributes_names = implode(', ', $attributes_names); $orderitem->attributes_codes = implode(', ', $attributes_codes); // adjust the price $orderitem->orderitem_price = $orderitem->orderitem_price + floatval($orderitem->orderitem_attributes_price); } //retrieve the order's history $model = JModelLegacy::getInstance('OrderHistory', 'CitruscartModel'); $model->setState('filter_orderid', $item->order_id); $model->setState('order', 'tbl.date_added'); $model->setState('direction', 'ASC'); $item->orderhistory = $model->getList($refresh); $item->link_view = 'index.php?option=com_citruscart&view=orders&task=view&id=' . $item->order_id; //retrieve the order's payments $model = JModelLegacy::getInstance('OrderPayments', 'CitruscartModel'); $model->setState('filter_orderid', $item->order_id); $model->setState('order', 'tbl.created_date'); $model->setState('direction', 'ASC'); $item->orderpayments = $model->getList($refresh); //retrieve the order's shippings $model = JModelLegacy::getInstance('OrderShippings', 'CitruscartModel'); $model->setState('filter_orderid', $item->order_id); $model->setState('order', 'tbl.created_date'); $model->setState('direction', 'ASC'); $item->ordershippings = $model->getList($refresh); //retrieve the order's taxclasses $model = JModelLegacy::getInstance('OrderTaxClasses', 'CitruscartModel'); $model->setState('filter_orderid', $item->order_id); $model->setState('order', 'tbl.ordertaxclass_description'); $model->setState('direction', 'ASC'); $item->ordertaxclasses = $model->getList($refresh); // retrieve the order's taxrates $model = JModelLegacy::getInstance('OrderTaxRates', 'CitruscartModel'); $model->setState('filter_orderid', $item->order_id); $model->setState('order', 'tbl.ordertaxclass_id, tbl.ordertaxrate_level'); $item->ordertaxrates = $model->getList($refresh); // retrieve the order's currency // this loads the currency, using the FK is it is the same of the // currency used in the order, or the DSCParameter currency of the order otherwise $order_currency = new DSCParameter($item->order_currency); $order_currency = $order_currency->toArray(); //$model = JModelLegacy::getInstance( 'Currencies', 'CitruscartModel' ); //$model->setId($item->currency_id); $item->currency = $currency_helper->load($item->currency_id); // if the order currency is not the same as it was during the order if (!empty($item->currency) && !empty($order_currency['currency_code']) && $item->currency->currency_code != $order_currency['currency_code']) { // overwrite it with the original one foreach ($order_currency as $k => $v) { $item->currency->{$k} = $v; } } // has a commission? if ($amigos->isInstalled()) { $item->commissions = $amigos->getCommissions($item->order_id); } } $this->_item = $item; } JFactory::getApplication()->triggerEvent('onPrepare' . $this->getTable()->get('_suffix'), array(&$this->_item)); return $this->_item; }
public function getItem($pk = null, $refresh = false, $emptyState = true) { if ($item = parent::getItem($pk, $refresh, $emptyState)) { $item->productfile_path = $this->correctPath($item->productfile_path); } return $item; }