/** * Charge la collection * * @return unknown */ protected function _prepareCollection() { //Charge la collection $collection = Mage::getModel('Purchase/StockMovement')->getCollection()->join('Purchase/CatalogProduct', 'sm_product_id=`Purchase/CatalogProduct`.entity_id')->join('Purchase/CatalogProductVarchar', 'sm_product_id=`Purchase/CatalogProductVarchar`.entity_id and store_id=0 and attribute_id = ' . mage::getModel('Purchase/Constant')->GetProductNameAttributeId()); $this->setCollection($collection); return parent::_prepareCollection(); }
public function render(Varien_Object $row) { //get planning $planning = $row->getPlanning(); //if no planning found, try to load it from order id if ($planning == null) { $orderId = $row->getopp_order_id(); $planning = mage::getModel('Purchase/SalesOrderPlanning')->load($orderId, 'psop_order_id'); } if ($planning) { $html = '<div class="nowrap" style="text-align: left;">'; if ($planning->getFullstockDate() != '') { $html .= mage::helper('purchase')->__('Prepare') . ' : <font color="' . $this->getColorForDate($planning->getFullstockDate()) . '">' . mage::helper('core')->formatDate($planning->getFullstockDate(), 'short') . '</font>'; } if ($planning->getShippingDate() != '') { $html .= '<br>' . mage::helper('purchase')->__('Ship') . ' : <font color="' . $this->getColorForDate($planning->getShippingDate()) . '">' . mage::helper('core')->formatDate($planning->getShippingDate(), 'short') . '</font>'; } if ($planning->getDeliveryDate() != '') { $html .= '<br>' . mage::helper('purchase')->__('Delivery') . ' <font color="' . $this->getColorForDate($planning->getDeliveryDate()) . '">: ' . mage::helper('core')->formatDate($planning->getDeliveryDate(), 'short') . '</font>'; } $html .= '</div>'; } else { $html = $this->__('No planning'); } return $html; }
public function getOrder() { if ($this->_order == null) { $this->_order = mage::getModel('Purchase/Order')->load($this->getRequest()->getParam('po_num')); } return $this->_order; }
/** * Set stocks updated to 1 for canceled orders * */ public function cleanCanceledOrders() { $collection = mage::getModel('sales/order')->getCollection()->addFieldToFilter('stocks_updated', 0)->addAttributeToFilter('status', 'canceled'); foreach ($collection as $order) { $order->setstocks_updated(1)->save(); } }
protected function _getLevels() { if (!$this->_levels) { $this->_levels = mage::getModel('ebayenterprise_magelog/system_config_source_log_levels'); } return $this->_levels; }
/** * * * @return Mage_Catalog_Model_Product */ public function getSupplier() { if ($this->_supplier == null) { $this->_supplier = mage::getModel('Purchase/Supplier')->load($this->getRequest()->getParam('sup_id')); } return $this->_supplier; }
/** * Load product collection Id(s) * */ public function load() { //Charge les commandes fournisseur $this->_collection = mage::getModel('Purchase/OrderProduct')->getCollection()->join('catalog/product', 'pop_product_id=entity_id')->setOrder('pop_order_num', 'asc'); //Affiche le nombre de commande chargée $this->addException(Mage::helper('dataflow')->__('Loaded %s rows', $this->_collection->getSize()), Mage_Dataflow_Model_Convert_Exception::NOTICE); }
/** * Load product collection Id(s) * */ public function load() { $nameAttributeId = mage::getModel('Purchase/Constant')->GetProductNameAttributeId(); $this->_collection = mage::getModel('Purchase/StockMovement')->getCollection()->setOrder('sm_date', 'asc')->join('catalog/product', 'sm_product_id=entity_id'); //Affiche le nombre de commande chargée $this->addException(Mage::helper('dataflow')->__('Loaded %s rows', $this->_collection->getSize()), Mage_Dataflow_Model_Convert_Exception::NOTICE); }
public function GetOrderPaymentValidatedAttributeId() { if ($this->_OrderPaymentValidatedAttributeId == null) { $this->_OrderPaymentValidatedAttributeId = mage::getModel('eav/entity_attribute')->loadByCode('order', 'payment_validated')->getId(); } return $this->_OrderPaymentValidatedAttributeId; }
/** * Load product collection Id(s) * */ public function load() { //Charge les commandes fournisseur $this->_collection = mage::getModel('Purchase/SupplyNeeds')->getCollection()->setOrder('sn_id', 'asc'); //Affiche le nombre de commande chargée $this->addException(Mage::helper('dataflow')->__('Loaded %s rows', $this->_collection->getSize()), Mage_Dataflow_Model_Convert_Exception::NOTICE); }
/** * Retourne le du produit courant * * @return unknown */ public function getProduct() { if ($this->_product == null) { $this->_product = mage::getModel('catalog/product')->load($this->_productId); } return $this->_product; }
public function render(Varien_Object $row) { //recupere les infos $orderItem = $row; $value = $orderItem->getreserved_qty(); //recupere le produit $product = mage::getModel('catalog/product')->load($orderItem->getproduct_id()); //si le produit ne gere pas les stocks if ($product->getStockItem()->getManageStock()) { if ($orderItem->getqty_ordered() - $orderItem->getRealShippedQty() == 0) { $retour = $this->__('Shipped'); } else { //si la qté est suffisante pour réserver ou déja réservé if ($product->CanReserveQty($orderItem->getqty_ordered()) || $value == $orderItem->getqty_ordered()) { if ($value > 0) { $checked = " checked "; } else { $checked = ""; } $retour = "<input type=\"checkbox\" name=\"qty_reserved_" . $orderItem->getId() . "\" values=\"1\" {$checked}>"; } else { $retour = "<font color=\"red\">" . $this->__('Stock Insufficient') . "</font>"; } } } else { $retour = "<font color=\"red\">" . $this->__('No Stock Management') . "</font>"; } //retourne return $retour; }
/** * Load product collection Id(s) * */ public function load() { //Charge les commandes fournisseur $this->_collection = mage::getModel('Orderpreparation/ordertoprepareitem')->getCollection()->join('sales/order_item', 'order_item_id=item_id'); //Affiche le nombre de commande chargée $this->addException(Mage::helper('dataflow')->__('Loaded %s rows', $this->_collection->getSize()), Mage_Dataflow_Model_Convert_Exception::NOTICE); }
/** * Retourne le dernier prix d'achat sans frais d'approche pour un produit * * @param unknown_type $ProductId */ public function GetLastPriceWithoutFees($ProductId) { $sql = 'select pop_price_ht_base from ' . mage::getModel('Purchase/Constant')->getTablePrefix() . 'purchase_order_product, ' . mage::getModel('Purchase/Constant')->getTablePrefix() . 'purchase_order where pop_order_num = po_num and po_status = \'' . MDN_Purchase_Model_Order::STATUS_COMPLETE . '\' and pop_price_ht_base > 0 and pop_product_id = ' . $ProductId . ' order by po_num DESC LIMIT 1'; $retour = mage::getResourceModel('sales/order_item_collection')->getConnection()->fetchOne($sql); $retour = number_format($retour, 2); return $retour; }
/** * Retourne le produit concerné * * @param unknown_type $value */ public function getProduct() { if ($this->_product == null) { $this->_product = mage::getModel('catalog/product')->load($this->getRequest()->getParam('product_id')); } return $this->_product; }
/** * Return shipping delay for carrier * */ public function getShippingDelayForCarrier($ShippingMethod, $Country) { $return = Mage::getStoreConfig('planning/delivery/default_shipping_delay'); //define carrier $Carrier = ''; $t = explode('_', $ShippingMethod); if (count($t) > 0) { $Carrier = $t[0]; } //load shipping delay for carrier $item = mage::getModel('Purchase/ShippingDelay')->load($Carrier, 'psd_carrier'); if ($item->getId()) { $return = $item->getpsd_default(); //check in exceptions if ($item->getpsd_exceptions() != '') { $exceptions = explode(',', $item->getpsd_exceptions()); for ($i = 0; $i < count($exceptions); $i++) { $values = explode(':', $exceptions[$i]); if (count($values) == 2) { if ($Country == $values[0]) { $return = $values[1]; } } } } } return $return; }
/** * Refresh list * */ public function RefreshList() { //truncate table Mage::getResourceModel('ExtensionConflict/ExtensionConflict')->TruncateTable(); //retrieve all config.xml $tConfigFiles = $this->getConfigFilesList(); //parse all config.xml $rewrites = array(); foreach ($tConfigFiles as $configFile) { $rewrites = $this->getRewriteForFile($configFile, $rewrites); } //insert in database foreach ($rewrites as $key => $value) { $t = explode('/', $key); $moduleName = $t[0]; $className = $t[1]; $record = mage::getModel('ExtensionConflict/ExtensionConflict'); $record->setec_core_module($moduleName); $record->setec_core_class($className); $rewriteClasses = join(', ', $value); $record->setec_rewrite_classes($rewriteClasses); if (count($value) > 1) { $record->setec_is_conflict(1); } $record->save(); } }
public function render(Varien_Object $row) { //retrieve information $productId = $this->getColumn()->getproduct_id(); $collection = mage::getModel('sales/order_item')->getCollection()->addFieldToFilter('order_id', $row->getId())->addFieldToFilter('product_id', $productId); //return value $retour = 0; switch ($this->getColumn()->getfield_name()) { case 'ordered_qty': foreach ($collection as $item) { $retour += (int) $item->getqty_ordered(); } break; case 'shipped_qty': foreach ($collection as $item) { $retour += (int) $item->getRealShippedQty(); } break; case 'remaining_qty': foreach ($collection as $item) { $retour += $item->getRemainToShipQty(); } break; case 'reserved_qty': foreach ($collection as $item) { $retour += (int) $item->getreserved_qty(); } break; } if ($retour == '') { $retour = '0'; } return $retour; }
/** * Method to calculate order weight depending of configuration * * @param unknown_type $order */ public function calculateOrderWeight($products) { $retour = 0; //If calculation is enabled if (mage::getStoreConfig('orderpreparation/order_weight_calculation/enable')) { //compute bulk product weight for ($i = 0; $i < count($products); $i++) { $productId = $products[$i]['product_id']; $product = mage::getModel('catalog/product')->load($productId); if ($product->getId()) { $qty = $products[$i]['qty']; $retour += $product->getWeight() * $qty; } } //Add additional weight $methodValue = mage::getStoreConfig('orderpreparation/order_weight_calculation/additional_weight_value'); switch (mage::getStoreConfig('orderpreparation/order_weight_calculation/additional_weight_method')) { case MDN_Orderpreparation_Model_OrderWeightCalculation::METHOD_ADD_FIX_WEIGHT: $retour += $methodValue; break; case MDN_Orderpreparation_Model_OrderWeightCalculation::METHOD_ADD_FIX_WEIGHT_PER_PRODUCT: for ($i = 0; $i < count($products); $i++) { $qty = $products[$i]['qty']; $retour += $qty * $methodValue; } break; case MDN_Orderpreparation_Model_OrderWeightCalculation::METHOD_ADD_PERCENT: $retour += $retour / 100 * $methodValue; break; } } return $retour; }
protected function _beforeToHtml() { $this->addTab('fullstockorders', array('label' => Mage::helper('customer')->__('Full stock Orders') . ' (' . mage::getModel('Orderpreparation/ordertoprepare')->getFullStockOrdersFromCache()->getSize() . ')', 'content' => $this->getLayout()->createBlock('Orderpreparation/FullStockOrders')->setTemplate('Orderpreparation/FullStockOrders.phtml')->toHtml())); $this->addTab('stocklessorders', array('label' => Mage::helper('customer')->__('Stockless Orders') . ' (' . mage::getModel('Orderpreparation/ordertoprepare')->getStockLessOrdersFromCache()->getSize() . ')', 'content' => $this->getLayout()->createBlock('Orderpreparation/StocklessOrders')->setTemplate('Orderpreparation/StocklessOrders.phtml')->toHtml())); $this->addTab('ignoredorders', array('label' => Mage::helper('customer')->__('Ignored Orders') . ' (' . mage::getModel('Orderpreparation/ordertoprepare')->getIgnoredOrdersFromCache()->getSize() . ')', 'content' => $this->getLayout()->createBlock('Orderpreparation/IgnoredOrders')->setTemplate('Orderpreparation/IgnoredOrders.phtml')->toHtml(), 'active' => true)); $this->addTab('selectedorders', array('label' => Mage::helper('customer')->__('Selected Orders') . ' (' . mage::getModel('Orderpreparation/ordertoprepare')->getSelectedOrders()->getSize() . ')', 'content' => $this->getLayout()->createBlock('Orderpreparation/SelectedOrders')->setTemplate('Orderpreparation/SelectedOrders.phtml')->toHtml(), 'active' => true)); return parent::_beforeToHtml(); }
/** * Charge la collection * * @return unknown */ protected function _prepareCollection() { //charge les mouvements de stock $product = mage::getModel('catalog/product')->load($this->getProductId()); $collection = $product->GetPendingOrders(false); $this->setCollection($collection); return parent::_prepareCollection(); }
/** * return current carrier template object * * @return unknown */ public function getCarrierTemplate() { if ($this->_carrierTemplate == null) { $templateId = $this->getRequest()->getParam('ct_id'); $this->_carrierTemplate = mage::getModel('Orderpreparation/CarrierTemplate')->load($templateId); } return $this->_carrierTemplate; }
public function getConflict() { if ($this->_conflict == null) { $ecId = $this->getRequest()->getParam('ec_id'); $this->_conflict = mage::getModel('ExtensionConflict/ExtensionConflict')->load($ecId); } return $this->_conflict; }
/** * Return template object for carrier * * @param unknown_type $carrier */ public function getTemplateForCarrier($shippingMethod) { $obj = mage::getModel('Orderpreparation/CarrierTemplate')->load($shippingMethod, 'ct_shipping_method'); if ($obj->getId()) { return $obj; } else { return null; } }
public function showShipmentAction() { $shipmentId = $this->getRequest()->getParam('shipment_id'); $shipment = mage::getModel('sales/order_shipment')->load($shipmentId); foreach ($shipment->getAllItems() as $item) { echo '<p>' . $item->getqty() . 'x ' . $item->getName(); } die('<p>---> Shipment : ' . $shipmentId); }
public function __construct() { parent::__construct(); $customerId = mage::getSingleton('customer/session')->getId(); $customer = mage::getModel('customer/customer')->load($customerId); if (is_object($customer) || $customer->getId()) { $this->_customer = $customer; } }
/** * Add a new task group * * @param unknown_type $groupCode * @param unknown_type $description * @param unknown_type $redirectUrl */ public function AddGroup($groupCode, $description, $redirectUrl) { //if group exists, exit $group = mage::getResourceModel('BackgroundTask/Taskgroup')->loadByGroupCode($groupCode); if (!$group) { $group = mage::getModel('BackgroundTask/Taskgroup')->setbtg_code($groupCode)->setbtg_description($description)->setbtg_redirect_url($redirectUrl)->save(); } return $group; }
/** * Return configurable product from simple product * * @param unknown_type $product */ public function getConfigurableProduct($product) { $parentIdArray = $this->getProductParentIds($product); foreach ($parentIdArray as $parentId) { $parent = mage::getModel('catalog/product')->load($parentId); return $parent; } return null; }
public function load() { //apaga todas as linhas antes de importar $regras = mage::getModel('regrasdefrete/regras')->getResourceCollection(); foreach ($regras as $regra) { $regra->delete(); } parent::load(); }
public function render(Varien_Object $row) { $retour = ''; $collection = mage::getModel('Purchase/ProductSupplier')->getCollection()->addFieldToFilter('pps_product_id', $row->getId())->join('Purchase/Supplier', 'pps_supplier_num=sup_id'); foreach ($collection as $supplier) { $retour .= $supplier->getsup_name() . ', '; } $retour = substr($retour, 0, strlen($retour) - 2); return $retour; }