本文整理汇总了PHP中mage::getResourceModel方法的典型用法代码示例。如果您正苦于以下问题:PHP mage::getResourceModel方法的具体用法?PHP mage::getResourceModel怎么用?PHP mage::getResourceModel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mage
的用法示例。
在下文中一共展示了mage::getResourceModel方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getGroup
public function getGroup()
{
if ($this->_group == null) {
$this->_group = mage::getResourceModel('BackgroundTask/Taskgroup')->loadByGroupCode($this->_groupCode);
}
return $this->_group;
}
示例2: GetLastPriceWithoutFees
/**
* 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;
}
示例3: ComputeProductStock
/**
* Calcul le stock pour un produit
*
*/
public function ComputeProductStock($ProductId)
{
$sql = '
select sum(sm_coef * sm_qty) stock
from ' . mage::getModel('Purchase/Constant')->getTablePrefix() . 'stock_movement
where sm_product_id = ' . $ProductId . '
';
$data = mage::getResourceModel('sales/order_item_collection')->getConnection()->fetchAll($sql);
if (count($data) > 0) {
if ($data[0]['stock'] == '') {
return 0;
} else {
return $data[0]['stock'];
}
}
return 0;
}
示例4: UpdateReservedQty
/**
* Met a jour la qté réservée
*
* @param unknown_type $qty
*/
public function UpdateReservedQty($product)
{
//recupere la qté
$reservedQty = $this->GetReservedQty($product->getId());
//check if record exists
$sql = 'select count(*) from ' . mage::getModel('Purchase/Constant')->getTablePrefix() . 'catalog_product_entity_int where entity_id = ' . $product->getId() . ' and attribute_id = ' . mage::getModel('Purchase/Constant')->GetProductReservedQtyAttributeId();
$res = mage::getResourceModel('sales/order_item_collection')->getConnection()->fetchOne($sql);
if ($res == 0) {
//insert record
$sql = 'insert into ' . mage::getModel('Purchase/Constant')->getTablePrefix() . 'catalog_product_entity_int (value, entity_id, attribute_id) values (' . $reservedQty . ', ' . $product->getId() . ', ' . mage::getModel('Purchase/Constant')->GetProductReservedQtyAttributeId() . ')';
$res = mage::getResourceModel('sales/order_item_collection')->getConnection()->query($sql);
} else {
//met a jour pour le produit
$sql = 'update ' . mage::getModel('Purchase/Constant')->getTablePrefix() . 'catalog_product_entity_int set value = ' . $reservedQty . ' where entity_id = ' . $product->getId() . ' and attribute_id = ' . mage::getModel('Purchase/Constant')->GetProductReservedQtyAttributeId();
mage::getResourceModel('sales/order_item_collection')->getConnection()->query($sql);
}
return;
}
示例5: ClearGroupTasksAction
/**
* Clear all tasks
*
*/
public function ClearGroupTasksAction()
{
mage::getResourceModel('BackgroundTask/Task')->deleteAllGroupTasks();
mage::getResourceModel('BackgroundTask/Taskgroup')->deleteAllGroups();
//confirm & redirect
Mage::getSingleton('adminhtml/session')->addSuccess($this->__('Group Tasks successfully deleted'));
$this->_redirect('BackgroundTask/Admin/Grid');
}
示例6: getCandidateProductIds
/**
* Return ids for product that must be in supply needs
*
*/
public function getCandidateProductIds()
{
//recupere les valeurs par défaut pour le store
$DefaultManageStock = Mage::getStoreConfig('cataloginventory/item_options/manage_stock');
if ($DefaultManageStock == '') {
$DefaultManageStock = 1;
}
$DefaultNotifyStockQty = Mage::getStoreConfig('cataloginventory/item_options/notify_stock_qty');
if ($DefaultNotifyStockQty == '') {
$DefaultNotifyStockQty = 0;
}
//retrieve concerned products
$sql = "\n\t\t\t\t\tselect \n\t\t\t\t\t\t\t" . mage::getModel('Purchase/Constant')->getTablePrefix() . "catalog_product_entity.entity_id product_id,\n\t\t\t\t\t\t\t" . mage::getModel('Purchase/Constant')->getTablePrefix() . "cataloginventory_stock_item.qty qty,\n\t\t\t\t\t\t\t" . mage::getModel('Purchase/Constant')->getTablePrefix() . "cataloginventory_stock_item.notify_stock_qty notify_stock_qty,\n\t\t\t\t\t\t\t" . mage::getModel('Purchase/Constant')->getTablePrefix() . "cataloginventory_stock_item.use_config_notify_stock_qty use_config_notify_stock_qty,\n\t\t\t\t\t\t\t" . mage::getModel('Purchase/Constant')->getTablePrefix() . "cataloginventory_stock_item.manage_stock manage_stock,\n\t\t\t\t\t\t\t" . mage::getModel('Purchase/Constant')->getTablePrefix() . "cataloginventory_stock_item.use_config_manage_stock use_config_manage_stock,\n\t\t\t\t\t\t\ttbl_ordered_qty.value ordered_qty\n\t\t\t\t\t\t\t\n\t\t\t\t\tfrom \t" . mage::getModel('Purchase/Constant')->getTablePrefix() . "catalog_product_entity,\n\t\t\t\t\t\t\t" . mage::getModel('Purchase/Constant')->getTablePrefix() . "cataloginventory_stock_item,\n\t\t\t\t\t\t\t" . mage::getModel('Purchase/Constant')->getTablePrefix() . "catalog_product_entity_int tbl_status,\n\t\t\t\t\t\t\t" . mage::getModel('Purchase/Constant')->getTablePrefix() . "catalog_product_entity_int tbl_ordered_qty\n\t\t\t\t\twhere \n\t\t\t\t\t\t\t" . mage::getModel('Purchase/Constant')->getTablePrefix() . "catalog_product_entity.entity_id = " . mage::getModel('Purchase/Constant')->getTablePrefix() . "cataloginventory_stock_item.product_id\n\t\t\t\t\t\t\tand " . mage::getModel('Purchase/Constant')->getTablePrefix() . "cataloginventory_stock_item.stock_id = 1\n\t\t\t\t\t\t\tand tbl_status.entity_id = " . mage::getModel('Purchase/Constant')->getTablePrefix() . "catalog_product_entity.entity_id\n\t\t\t\t\t\t\tand tbl_status.attribute_id = " . mage::getModel('Purchase/Constant')->GetProductStatusAttributeId() . "\n\t\t\t\t\t\t\tand tbl_status.value = 1\n\t\t\t\t\t\t\tand tbl_status.store_id = 0\n\t\t\t\t\t\t\tand tbl_ordered_qty.entity_id = " . mage::getModel('Purchase/Constant')->getTablePrefix() . "catalog_product_entity.entity_id\n\t\t\t\t\t\t\tand tbl_ordered_qty.attribute_id = " . mage::getModel('Purchase/Constant')->GetProductOrderedQtyAttributeId() . "\n\t\t\t\t\t\t\tand tbl_ordered_qty.store_id = 0\n\t\t\t\t\t\t\tand " . mage::getModel('Purchase/Constant')->getTablePrefix() . "catalog_product_entity.exclude_from_supply_needs = 0\n\t\t\t\t";
$data = mage::getResourceModel('sales/order_item_collection')->getConnection()->fetchAll($sql);
return $data;
}
示例7: SaveAction
/**
* Enregistre les modifs faite sur le manufacturer
*
*/
public function SaveAction()
{
//Charge le manufacturer
$Manufacturer = Mage::getModel('Purchase/Manufacturer')->load($this->getRequest()->getParam('man_id'));
//Enregistre les modifs
$Manufacturer->setman_name($this->getRequest()->getParam('man_name'));
$Manufacturer->setman_contact($this->getRequest()->getParam('man_contact'));
$Manufacturer->setman_address1($this->getRequest()->getParam('man_address1'));
$Manufacturer->setman_address2($this->getRequest()->getParam('man_address2'));
$Manufacturer->setman_zipcode($this->getRequest()->getParam('man_zipcode'));
$Manufacturer->setman_city($this->getRequest()->getParam('man_city'));
$Manufacturer->setman_country($this->getRequest()->getParam('man_country'));
$Manufacturer->setman_tel($this->getRequest()->getParam('man_tel'));
$Manufacturer->setman_fax($this->getRequest()->getParam('man_fax'));
$Manufacturer->setman_email($this->getRequest()->getParam('man_email'));
$Manufacturer->setman_website($this->getRequest()->getParam('man_website'));
$Manufacturer->setman_comments($this->getRequest()->getParam('man_comments'));
$Manufacturer->setman_attribute_option_id($this->getRequest()->getParam('man_attribute_option_id'));
//Si on doit créer le manufacturer magento
if ($this->getRequest()->getParam('create_magento_manufacturer') == '1') {
//cree l'option
$option['attribute_id'] = mage::getModel('Purchase/Constant')->GetProductManufacturerAttributeId();
$option['value'][0][0] = $Manufacturer->getman_name();
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$setup->addAttributeOption($option);
//recupere son id
$OptionId = null;
$sql = "\n\t\t\t\tSELECT \n\t\t\t\t\t" . mage::getModel('Purchase/Constant')->getTablePrefix() . "eav_attribute_option_value.option_id id, " . mage::getModel('Purchase/Constant')->getTablePrefix() . "eav_attribute_option_value.value name\n\t\t\t\tfrom \n\t\t\t\t\t" . mage::getModel('Purchase/Constant')->getTablePrefix() . "eav_attribute_option,\n\t\t\t\t\t" . mage::getModel('Purchase/Constant')->getTablePrefix() . "eav_attribute_option_value\n\t\t\t\twhere \n\t\t\t\t\t" . mage::getModel('Purchase/Constant')->getTablePrefix() . "eav_attribute_option.attribute_id = " . mage::getModel('Purchase/Constant')->GetProductManufacturerAttributeId() . "\n\t\t\t\t\tand " . mage::getModel('Purchase/Constant')->getTablePrefix() . "eav_attribute_option.option_id = " . mage::getModel('Purchase/Constant')->getTablePrefix() . "eav_attribute_option_value.option_id \n\t\t\t\t\torder by " . mage::getModel('Purchase/Constant')->getTablePrefix() . "eav_attribute_option_value.value\n\t\t\t\t";
//execute la requete
$data = mage::getResourceModel('sales/order_item_collection')->getConnection()->fetchAll($sql);
for ($i = 0; $i < count($data); $i++) {
if ($data[$i]['name'] == $Manufacturer->getman_name()) {
$OptionId = $data[$i]['id'];
}
}
//l'associe
$Manufacturer->setman_attribute_option_id($OptionId);
}
$Manufacturer->save();
//confirme
Mage::getSingleton('adminhtml/session')->addSuccess($this->__('Manufacturer Saved'));
//Redirige vers la fiche créée
$this->_redirect('Purchase/Manufacturers/Edit/man_id/' . $Manufacturer->getId());
}
示例8: getIngoingMovement
public function getIngoingMovement($from, $to, $productId)
{
$tablePrefix = Mage::getConfig()->getTablePrefix();
$sql = "select sum(sm_qty * sm_coef) from " . $tablePrefix . "stock_movement where sm_coef > 0 and sm_product_id=" . $productId . " and sm_date >= '" . date('Y-m-d', $from) . "' and sm_date <= '" . date('Y-m-d', $to) . "'";
$retour = mage::getResourceModel('sales/order_item_collection')->getConnection()->fetchOne($sql);
return abs((int) $retour);
}
示例9: UpdateStocksForOrders
/**
* Méthode appelée par le cron pour mettre a jour les qte commandés des produits
*
*/
public function UpdateStocksForOrders()
{
//Parcourt les commandes dont les stocks n'ont pas été mis a jour (stocks_updated = 0)
echo '<h2>UpdateStocksForOrders</h2>';
$sql = 'select entity_id from ' . mage::getModel('Purchase/Constant')->getTablePrefix() . 'sales_order where stocks_updated = 0';
$data = mage::getResourceModel('sales/order_item_collection')->getConnection()->fetchAll($sql);
for ($i = 0; $i < count($data); $i++) {
//Charge la commande
$order = mage::getModel('sales/order')->load($data[$i]['entity_id']);
echo '<p><b>Processing order #' . $order->getId() . '</b>';
//Si la commande remplit les conditions
if ($order->IsValidForPurchaseProcess()) {
try {
//Pour chaque produit de la commande
foreach ($order->getAllItems() as $item) {
if ($item->getproduct_id()) {
//charge le produit
$product = mage::getModel('catalog/product')->load($item->getproduct_id());
if ($product->getId() != '') {
echo '<br>Updating product ordered qty for product #' . $product->getId();
//reserve le produit si possible
$model = mage::getModel('Purchase/Productstock');
mage::helper('purchase/ProductReservation')->reserveProductForOrder($order->getId(), $product->getId());
//met a jour les qte (reservée et ordered)
echo '<br>Update ordered and reserved qty';
$model->UpdateOrderedQty($product);
}
}
}
} catch (Exception $ex) {
echo 'Error while browsing products : ' . $ex->getMessage() . ' <br> ' . $ex->getTraceAsString();
}
//Specifie que le stock a été mis a jour
$sql = 'update ' . mage::getModel('Purchase/Constant')->getTablePrefix() . 'sales_order set stocks_updated = 1 where entity_id = ' . $data[$i]['entity_id'];
echo '<br>' . $sql;
mage::getResourceModel('sales/order_item_collection')->getConnection()->query($sql);
//dispatch order in order preparation tabs
mage::helper('BackgroundTask')->AddTask('Dispatch order #' . $order->getId(), 'Orderpreparation', 'dispatchOrder', $order->getId());
//Store planning
try {
echo '<br>Store planning';
$planning = mage::helper('purchase/Planning')->createPlanning($order);
$planning->setpsop_anounced_date($planning->getpsop_delivery_date());
$planning->setpsop_anounced_date_max($planning->getpsop_delivery_date_max());
$planning->save();
} catch (Exception $ex) {
echo '<font color="red">Error creating order planning: ' . $ex->getMessage() . '</font>';
}
//update supply needs for products
/*
foreach($order->getAllItems() as $item)
{
$productId = $item->getproduct_id();
Mage::dispatchEvent('purchase_update_supply_needs_for_product', array('product_id'=>$productId, 'from' => 'order #'.$order->getId().' placed'));
}
*/
} else {
echo '<p>Order doesnt fullfill supplyneeds and reservation requiresites. Stocks not updated';
}
}
}
示例10: _afterDelete
/**
* Delete group's tasks
*
*/
protected function _afterDelete()
{
mage::getResourceModel('BackgroundTask/Task')->deleteGroupTasks($this->getbtg_code());
}
示例11: getNextTaskToExecute
/**
* Collect next task to execute
*
*/
public function getNextTaskToExecute()
{
$collection = mage::getResourceModel('BackgroundTask/Task_Collection')->getNextTaskToExecute();
foreach ($collection as $item) {
return $item;
}
}
示例12: getList
/**
* Retourne la liste des erreurs
*
*/
public function getList()
{
$retour = array();
$ProductStockModel = mage::getModel('Purchase/Productstock');
//Recupere la liste des produits
$sql = '
select
product_id,
qty,
tbl_ordered.value ordered_qty,
tbl_reserved.value reserved_qty,
tbl_name.value name
from
' . mage::getModel('Purchase/Constant')->getTablePrefix() . 'catalog_product_entity,
' . mage::getModel('Purchase/Constant')->getTablePrefix() . 'cataloginventory_stock_item,
' . mage::getModel('Purchase/Constant')->getTablePrefix() . 'catalog_product_entity_int tbl_ordered,
' . mage::getModel('Purchase/Constant')->getTablePrefix() . 'catalog_product_entity_int tbl_reserved,
' . mage::getModel('Purchase/Constant')->getTablePrefix() . 'catalog_product_entity_varchar tbl_name
where
' . mage::getModel('Purchase/Constant')->getTablePrefix() . 'catalog_product_entity.entity_id = ' . mage::getModel('Purchase/Constant')->getTablePrefix() . 'cataloginventory_stock_item.product_id
and ' . mage::getModel('Purchase/Constant')->getTablePrefix() . 'catalog_product_entity.entity_id = tbl_ordered.entity_id
and ' . mage::getModel('Purchase/Constant')->getTablePrefix() . 'catalog_product_entity.entity_id = tbl_reserved.entity_id
and tbl_reserved.attribute_id = ' . mage::getModel('Purchase/Constant')->GetProductReservedQtyAttributeId() . '
and tbl_ordered.attribute_id = ' . mage::getModel('Purchase/Constant')->GetProductOrderedQtyAttributeId() . '
and tbl_name.entity_id = tbl_ordered.entity_id
and tbl_name.attribute_id = ' . mage::getModel('Purchase/Constant')->GetProductNameAttributeId() . '
and ' . mage::getModel('Purchase/Constant')->getTablePrefix() . 'catalog_product_entity.type_id = \'simple\'
order by
' . mage::getModel('Purchase/Constant')->getTablePrefix() . 'catalog_product_entity.entity_id
';
$data = mage::getResourceModel('sales/order_item_collection')->getConnection()->fetchAll($sql);
for ($i = 0; $i < count($data); $i++) {
$AddProduct = false;
$StockProblem = false;
$OrderedProblem = false;
$ReservedProblem = false;
$productId = $data[$i]['product_id'];
//Recupere le stock calcué via les mouvements de stock
$CalculatedStock = (int) $ProductStockModel->ComputeProductStock($productId);
if ($CalculatedStock != $data[$i]['qty']) {
$AddProduct = true;
$StockProblem = true;
}
//Recupere le stock calcué via les mouvements de stock
$OrderedQty = (int) $ProductStockModel->GetOrderedQty($productId);
if ($OrderedQty != $data[$i]['ordered_qty']) {
$AddProduct = true;
$OrderedProblem = true;
}
//Recupere le stock calcué via les mouvements de stock
$ReservedQty = (int) mage::helper('purchase/ProductReservation')->GetReservedQty($productId);
if ($ReservedQty != $data[$i]['reserved_qty']) {
$AddProduct = true;
$ReservedProblem = true;
}
if ($ReservedQty > $CalculatedStock) {
$AddProduct = true;
}
if ($ReservedQty > $OrderedQty) {
$AddProduct = true;
}
//Si le produit a un pb
if ($AddProduct) {
$item = array();
$item['product_name'] = '<a href="' . $this->getUrl('Purchase/Products/Edit', array('product_id' => $productId)) . '">' . $data[$i]['name'] . ' (' . $productId . ')</a>';
$item['ordered_qty'] = '';
$item['reserved_qty'] = '';
$item['product_id'] = $productId;
$item['other'] = '';
$item['stock'] = '';
if ($StockProblem) {
$item['stock'] = '<font color="red">Error (' . (int) $data[$i]['qty'] . ' / ' . $CalculatedStock . ')</font>';
} else {
$item['stock'] = $CalculatedStock;
}
if ($OrderedProblem) {
$item['ordered_qty'] = '<font color="red">Error (' . (int) $data[$i]['ordered_qty'] . ' / ' . $OrderedQty . ')</font>';
} else {
$item['ordered_qty'] = $OrderedQty;
}
if ($ReservedProblem) {
$item['reserved_qty'] = '<font color="red">Error (' . (int) $data[$i]['reserved_qty'] . ' / ' . $ReservedQty . ')</font>';
} else {
$item['reserved_qty'] = $ReservedQty;
}
if ($ReservedQty > $CalculatedStock) {
$item['other'] .= '<font color="red">Reserved qty > stock</font>';
}
if ($ReservedQty > $OrderedQty) {
$item['other'] .= '<font color="red">Reserved qty > ordered qty</font>';
}
$retour[] = $item;
}
}
//retourne
return $retour;
//.........这里部分代码省略.........