/** * Render minimal price for downloadable products * * @param Varien_Object $row * @return string */ public function render(Varien_Object $row) { if ($row->getTypeId() == 'downloadable') { $row->setPrice($row->getPrice()); } $Product = Mage::getModel('catalog/product')->load($row->getData('entity_id')); if (Mage::helper('request4quote')->isRentalInstalled()) { if ($row->getTypeId() == ITwebexperts_Payperrentals_Helper_Data::PRODUCT_TYPE || $Product->getIsReservation() != ITwebexperts_Payperrentals_Model_Product_Isreservation::STATUS_DISABLED) { $row->setPrice(''); } } return parent::render($row); }
public function render(Varien_Object $row) { $html = ''; $manage_stock = Mage::getStoreConfig("cataloginventory/item_options/manage_stock"); if ($row->getManageStock() || $row->getUse_config_manage_stock() && $manage_stock) { if (in_array($row->getTypeId(), array('simple', 'virtual', 'downloadable'))) { $permissions = Mage::helper('advancedinventory/permissions')->getUserPermissions(); $all = $permissions->isAdmin(); $pos = $permissions->getPos(); if ($this->getStoreId()) { $places = Mage::getModel('pointofsale/pointofsale')->getPlacesByStoreId($this->getStoreId()); } else { $places = Mage::getModel('pointofsale/pointofsale')->getPlaces(); } $html = (int) 0; foreach ($places as $p) { if (in_array($p->getPlaceId(), $pos) || $all) { $data = Mage::getModel('advancedinventory/stock')->getStockByProductIdAndPlaceId($row->getId(), $p->getPlaceId()); $html += $data["quantity_in_stock"]; } } } else { $html = "-"; } $enabled = $row->getMultistock_enabled() ? 'enabled' : 'disabled'; return "<span class='GlobalQty' id='GlobalQty_" . $row->getId() . "' multistock='" . $enabled . "'>" . $html . "</span>"; } else { return Mage::helper('advancedinventory')->__("X"); } }
/** * Render minimal price for downloadable products * * @param Varien_Object $row * @return string */ public function render(Varien_Object $row) { if ($row->getTypeId() == 'downloadable') { $row->setPrice($row->getPrice()); } return parent::render($row); }
/** * Render minimal price for downloadable products * * @param Varien_Object $row * @return string */ public function render(Varien_Object $row) { if ($row->getTypeId() == Mage_Downloadable_Model_Product_Type::TYPE_DOWNLOADABLE) { $row->setPrice($row->getPrice()); } return parent::render($row); }
public function render(Varien_Object $row) { $manage_stock = Mage::getStoreConfig("cataloginventory/item_options/manage_stock"); if ($row->getManageStock() || $row->getUse_config_manage_stock() && $manage_stock) { if (in_array($row->getTypeId(), array('simple', 'virtual', 'downloadable'))) { $data = Mage::getModel('advancedinventory/stock')->getStockByProductIdAndPlaceId($row->getId(), $this->getColumn()->getPlaceId()); $qty = (int) $data->getQuantityInStock(); $enabled = $data->getManageStock(); if (!$row->getMultistock_enabled()) { $html = "-"; } else { if (!$enabled) { return Mage::helper('advancedinventory')->__("X"); } else { $html = "<input class='keydown inventory_input' value='" . $qty . "' / >"; } if (Mage::helper("advancedinventory/data")->isBackorderable($data)) { $html .= "<div title='Backorder allowed' class='ai-marker backorder'></div>"; } } } else { $html = "-"; } return "<span class='PosQty' id='PosQty_" . $row->getId() . "_" . $this->getColumn()->getPlaceId() . "'>" . $html . "</span>"; } else { return Mage::helper('advancedinventory')->__("X"); } }
public function testTransitionProductTypeVirtualToSimple() { $this->markTestIncomplete('MAGETWO-4796'); $product = new Varien_Object(array('type_id' => 'virtual')); $this->_observer = new Varien_Event_Observer(array('product' => $product)); $this->_model->transitionProductType($this->_observer); $this->assertEquals('simple', $product->getTypeId()); }
public function render(Varien_Object $row) { if (!in_array($row->getTypeId(), array('simple', 'virtual', 'downloadable'))) { return Mage::helper('advancedinventory')->__("-"); } $checked = $row->getStock_status() ? 'checked' : ''; $disabled = Mage::getStoreConfig("advancedinventory/setting/auto_update_stock_status") ? 'disabled' : ''; $html = "<div style='text-align:center'><input {$checked} {$disabled} name='' class='StockStatus ' type='checkbox' value = '" . (int) $row->getIsInStock() . "' /></div>"; return $html; }
public function render(Varien_Object $row) { $permissions = Mage::helper('advancedinventory/permissions')->getUserPermissions(); $all = $permissions->isAdmin(); $pos = $permissions->getPos(); if (in_array($row->getTypeId(), array('simple', 'virtual', 'downloadable'))) { if (!$all) { $html = array(); foreach ($pos as $p) { $stock = Mage::getModel("advancedinventory/stock")->getStockByProductIdAndPlaceId($row->getId(), $p); if ($stock->getManageLocalStock()) { $html[] = "<span style='font-size:11px;'>" . Mage::getModel("pointofsale/pointofsale")->load($p)->getName() . " (" . $stock->getQuantityInStock() . ")</span> "; } } if (!count($html)) { return "-"; } return "<div style='text-align:left'>" . implode('<br>', $html) . "</div>"; } $stock = Mage::getModel("advancedinventory/stock")->getMultiStockEnabledByProductId($row->getId()); if ($stock) { echo "<script type='text/javascript'>" . " function myOpenPopulate() {\r\n return true;\r\n }" . "var struct= new Array;"; if (Mage::app()->getRequest()->getParam('store') == Mage_Core_Model_App::ADMIN_STORE_ID) { $websites = Mage::app()->getWebsites(); foreach ($websites as $website) { $w[$website->getId()] = array(); foreach ($website->getGroups() as $group) { $g[$group->getId()] = array(); $stores = $group->getStores(); foreach ($stores as $store) { $w[$website->getId()][] = $store->getId(); $g[$group->getId()][] = $store->getId(); $s[$store->getId()] = Mage::getModel("advancedinventory/stock")->getStockByProductIdAndStoresId($row->getId(), $store->getId())->getQty(); } } } foreach ($websites as $website) { $qty = (int) Mage::getModel("advancedinventory/stock")->getStockByProductIdAndStoresId($row->getId(), $w[$website->getId()])->getQty(); echo "struct.push(\r\n {\r\n 'id': 'w" . $website->getId() . "-p" . $row->getId() . "',\r\n 'txt': '<b><u>" . $website->getName() . " (" . $qty . ")</u></b>',\r\n 'onopenpopulate' : myOpenPopulate,\r\n 'openlink' : '" . Mage::getUrl('*/stocks/treeview', array("type" => "storegroup", 'instanceid' => $website->getId(), "productid" => $row->getId())) . "',\r\n 'canhavechildren' : true\r\n }\r\n );"; } } else { $storeId = Mage::app()->getRequest()->getParam('store'); $qty = Mage::getModel("advancedinventory/stock")->getStockByProductIdAndStoresId($row->getId(), $storeId)->getQty(); echo "struct.push(\r\n {\r\n 'id': 's" . $storeId . "-p" . $row->getId() . "',\r\n 'txt': '" . Mage::app()->getStore($storeId)->getName() . " (" . (int) $qty . ")',\r\n 'onopenpopulate' : myOpenPopulate,\r\n 'openlink' : '" . Mage::getUrl('*/stocks/treeview', array("type" => "pos", 'instanceid' => $storeId, "productid" => $row->getId())) . "',\r\n 'canhavechildren' : true\r\n });"; } echo "</script>"; echo '<div id="myTree_' . $row->getId() . '"></div>'; echo "\r\n <script type='text/javascript'>\r\n \r\n trees.push(new TafelTree('myTree_" . $row->getId() . "', struct, {\r\n 'generate': true,\r\n 'imgBase': '" . Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN) . "/adminhtml/default/default/advancedinventory/images/',\r\n 'openAtLoad': false,\r\n 'cookies': false\r\n }));\r\n \r\n </script>\r\n "; } else { return "-"; } } else { return "-"; } }
public function render(Varien_Object $row) { if (in_array($row->getTypeId(), array('simple', 'virtual', 'downloadable'))) { if ($row->getManageLocalStock()) { return '<span id="foo_total_local_stock_qty_' . $row->getId() . '">' . $row->getTotalLocalQty() . "</span><input id='total_local_stock_qty_" . $row->getId() . "' type='hidden' value='" . $row->getStockId() . "' name='inventory[" . $row->getId() . "][total_local_stock_qty]'/>"; } else { return '<span id="foo_total_local_stock_qty_' . $row->getId() . '">-</span>' . "<input type='hidden' id='total_local_stock_qty_" . $row->getId() . "' value='" . $row->getStockId() . "' name='inventory[" . $row->getId() . "][total_local_stock_qty]'/>"; } } else { return "-"; } }
public function _getValue(Varien_Object $row) { if ($row->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_SIMPLE) { $value = '<span id="qty_label_' . $row->getId() . '" data-id="' . $row->getId() . '">' . (int) $row->getQty() . '</span>'; $value .= '<input type="text" id="qty_value_' . $row->getId() . '" name="qty_value[' . $row->getId() . ']" data-id="' . $row->getId() . '" value="' . (int) $row->getQty() . '" style="width: 100px;margin-right: 2px;display:none">'; $value .= '<button id="qty_button_' . $row->getId() . '" data-id="' . $row->getId() . '" onclick="vcUpdateInfor(' . $row->getId() . ',\'qty\')" style="display:none"><span><span>Update</span></span></button>'; $value .= '<img id="qty_waiting_' . $row->getId() . '" src="' . $this->getSkinUrl('vc_easyupdateproductinfor/images/ajax-loader.gif') . '" class="v-middle" style="display:none" />'; } else { $value = number_format($row->getQty(), 0); } return $value; }
/** * Renders grid column * * @param Varien_Object $row * @return string */ public function render(Varien_Object $_row) { $data = $_row->getData($this->getColumn()->getIndex()); $priceAmount = 0; if ($data && $_row->getTypeId() != 'reservation') { $priceAmount = $data; } elseif ($_row->hasData('reservation_price')) { $priceAmount = $_row->getData('reservation_price'); } elseif (is_null($data) || $_row->getTypeId() == 'reservation') { $product = $_row->load($_row->getId()); if ($product->getTypeId() != ITwebexperts_Payperrentals_Helper_Data::PRODUCT_TYPE_BUNDLE || $product->getBundlePricingtype() == ITwebexperts_Payperrentals_Model_Product_Bundlepricingtype::PRICING_BUNDLE_FORALL) { /** TODO move calculation to mysql join first record */ $priceCollection = Mage::getModel('payperrentals/reservationprices')->getCollection()->addFieldToFilter('entity_id', array('eq' => $_row->getData('entity_id'))); if (count($priceCollection)) { $firstRecord = $priceCollection->getFirstItem(); $priceAmount = $firstRecord->getPrice(); $_row->setData('reservation_number', $firstRecord->getNumberof()); $_row->setData('price_type', $firstRecord->getPtype()); } } elseif ($product->getTypeId() == ITwebexperts_Payperrentals_Helper_Data::PRODUCT_TYPE_BUNDLE) { $priceAmount = 0; } } if ($priceAmount) { $data = floatval($priceAmount) * $this->_getRate($_row); $currency_code = $this->_getCurrencyCode($_row); if (!$currency_code) { return $data; } $data = sprintf("%f", $data); $data = Mage::app()->getLocale()->currency($currency_code)->toCurrency($data); if ($_row->hasData('reservation_number') && $_row->hasData('price_type')) { $periodAr = Mage::getModel('payperrentals/product_periodtype')->getOptionArray($_row->getData('reservation_number')); $data .= '/<b>' . $_row->getData('reservation_number') . ' ' . $periodAr[$_row->getData('price_type')] . '</b>'; } return $data; } return $this->getColumn()->getDefault(); }
public function render(Varien_Object $row) { if (in_array($row->getTypeId(), array('simple', 'virtual', 'downloadable'))) { if (Mage::getStoreConfig("advancedinventory/setting/lock_online_stock") && $row->getManageLocalStock()) { $html = "<span id='foo_online_stock_qty_" . $row->getId() . "'>" . number_format($row->getOnlineQty(), 0, '', '') . "</span><input id='online_stock_qty_" . $row->getId() . "' class='keydown online_stock_qty' type='text' productid='" . $row->getId() . "' style='display:none;text-align:center; width:50px;' name='inventory[" . $row->getId() . "][online_stock_qty]' value='" . number_format($row->getOnlineQty(), 0, '', '') . "' onchange='InventoryManager.updateStocks(" . $row->getId() . ",false)'/>"; } else { $html = "<span style='display:none;' id='foo_online_stock_qty_" . $row->getId() . "'>" . number_format($row->getOnlineQty(), 0, '', '') . "</span><input id='online_stock_qty_" . $row->getId() . "' class='keydown online_stock_qty' type='text' productid='" . $row->getId() . "' style='text-align:center; width:50px;' name='inventory[" . $row->getId() . "][online_stock_qty]' value='" . number_format($row->getOnlineQty(), 0, '', '') . "' onchange='InventoryManager.updateStocks(" . $row->getId() . ",false)'/>"; } return "<input type='hidden' value='" . $row->getStockId() . "' id='inventory_" . $row->getId() . "_local_stock_id' name='inventory[" . $row->getId() . "][local_stock_id]' / >" . $html; } else { return "0"; } }
public function render(Varien_Object $row) { if (in_array($row->getTypeId(), array('simple', 'virtual', 'downloadable'))) { $actions[] = array('url' => "javascript:InventoryManager.save('" . $this->getUrl('*/*/save', array('id' => $row->getId())) . "','" . $row->getId() . "')", 'caption' => Mage::helper('advancedinventory')->__('Save'), 'id' => 'save'); if (Mage::getModel('pointofsale/pointofsale')->getPlaces()->count()) { if (Mage::getStoreConfig("advancedinventory/setting/lock_online_stock")) { $actions[] = array('caption' => Mage::helper('advancedinventory')->__("Sync. global stock"), 'url' => "javascript:InventoryManager.recalculate( " . $row->getId() . ")", 'id' => 'synchronize'); } $actions[] = array('caption' => Mage::helper('advancedinventory')->__(!$row->getManageLocalStock() ? Mage::helper('advancedinventory')->__("Enable local stocks") : Mage::helper('advancedinventory')->__("Disable local stocks")), 'url' => "javascript:InventoryManager.displayLocalStocks( " . $row->getId() . "," . (!$row->getManageLocalStock() ? "true" : "false") . ")", 'id' => 'enable'); } } $actions[] = array('url' => $this->getUrl('adminhtml/catalog_product/edit', array('id' => $row->getId(), "tab" => "product_info_tabs_inventory")), 'caption' => Mage::helper('advancedinventory')->__('Edit'), 'popup' => true, 'id' => 'edit'); $this->getColumn()->setActions($actions); return parent::render($row); }
public function render(Varien_Object $row) { $manage_stock = Mage::getStoreConfig("cataloginventory/item_options/manage_stock"); if (!in_array($row->getTypeId(), array('simple', 'virtual', 'downloadable'))) { return Mage::helper('advancedinventory')->__("-"); } if ($row->getManageStock() || $row->getUse_config_manage_stock() && $manage_stock) { if ($row->getMultistock_enabled()) { $html = (int) $row->getQty(); } else { $html = "<input class = 'keydown inventory_input' type = 'text' value = '" . (int) $row->getQty() . "' />"; } $enabled = $row->getMultistock_enabled() ? 'enabled' : 'disabled'; return "<span class = 'GlobalQty' id = 'GlobalQty_" . $row->getId() . "' multistock = '" . $enabled . "'>" . $html . "</span>"; } else { return Mage::helper('advancedinventory')->__("X"); } }
public function render(Varien_Object $row) { if (in_array($row->getTypeId(), array('simple', 'virtual', 'downloadable'))) { if (!$row->getManageLocalStock()) { $html = "<span id='stock_difference_" . $row->getId() . "' style=''>-</span>"; } else { if ($row->getDifference() == 0) { $html = "<span id='stock_difference_" . $row->getId() . "' style='color:green'> == </span>"; } elseif ($row->getDifference() > 0) { $html = "<span id='stock_difference_" . $row->getId() . "' style='color:red'> <b style='font-size:16px;'>> </b> (+" . $row->getDifference() . ") </span>"; } else { $html = "<span id='stock_difference_" . $row->getId() . "' style='color:orange; '><b style='font-size:16px;'>< </b>(" . $row->getDifference() . ")</span>"; } } return "<input type='hidden' value='" . $row->getManageLocalStock() . "' id='manage_local_stock_" . $row->getId() . "' name='inventory[" . $row->getId() . "][manage_local_stock]'>" . $html; } else { return "-"; } }
public function render(Varien_Object $row) { if (in_array($row->getTypeId(), array('simple', 'virtual', 'downloadable'))) { $data = Mage::getModel('advancedinventory/advancedinventory')->getLocalStockQty($row->getId(), $this->getColumn()->getPlaceId()); $data->getQuantityInStock() ? $value = $data->getQuantityInStock() : ($value = 0); if (in_array($this->getColumn()->getCurrentStore(), explode(',', $this->getColumn()->getStoreId())) || $this->getColumn()->getCurrentStore() == 0) { $disabled = ''; } else { $disabled = 'disabled'; } if (!$row->getManageLocalStock()) { return "<span class='foo_local_stock_qty_" . $row->getId() . "'>-</span>\n <input class='keydown " . $disabled . " local_stock_qty_" . $row->getId() . "' disabled type='text' onchange='InventoryManager.updateStocks(" . $row->getId() . ",false)' style='display:none;text-align:center; width:50px;' name='inventory[" . $row->getId() . "][local_stock][" . $this->getColumn()->getPlaceId() . "][qty]' value='" . $value . "'/>\n <input type='hidden' value='" . $data->getId() . "' id='inventory_" . $row->getId() . "_local_stock_" . $this->getColumn()->getPlaceId() . "_stock_id' name='inventory[" . $row->getId() . "][local_stock][" . $this->getColumn()->getPlaceId() . "][stock_id]'/>"; } else { return "<span class='foo_local_stock_qty_" . $row->getId() . "' style='display:none'>-</span>\n <input class='keydown " . $disabled . " local_stock_qty_" . $row->getId() . "' onchange='InventoryManager.updateStocks(" . $row->getId() . ",false)' {$disabled} type='text' style='text-align:center; width:50px;' name='inventory[" . $row->getId() . "][local_stock][" . $this->getColumn()->getPlaceId() . "][qty]' value='" . $value . "' / >\n <input type='hidden' value='" . $data->getId() . "' id='inventory_" . $row->getId() . "_local_stock_" . $this->getColumn()->getPlaceId() . "_stock_id' name='inventory[" . $row->getId() . "][local_stock][" . $this->getColumn()->getPlaceId() . "][stock_id]' / > "; } } else { return "-"; } }
public function render(Varien_Object $row) { if (in_array($row->getTypeId(), array('simple', 'virtual', 'downloadable'))) { $localQty = Mage::getModel('advancedinventory/advancedinventory')->getLocalGlobalStockByProductId($row->getId()); $diff = $row->getQty() - $localQty->getTotalQuantityInStock(); if (!$localQty->getManageLocalStock()) { $html = "<span id='stock_difference_" . $row->getId() . "' style=''>-</span>"; } else { if ($diff == 0) { $html = "<span style='color:green'> == </span>"; } elseif ($diff > 0) { $html = "<span style='color:red'><b style='font-size:16px;'>> </b> (+ " . $diff . ")</span>"; } else { $html = "<span style='color:orange; '><b style='font-size:16px;'>< </b> (" . $diff . ")</span>"; } } return $html; } else { return "-"; } }
public function render(Varien_Object $row) { $html = ''; if (in_array($row->getTypeId(), array('simple', 'virtual', 'downloadable'))) { if ($this->getStoreId()) { $places = Mage::getModel('pointofsale/pointofsale')->getPlacesByStoreId($this->getStoreId()); } else { $places = Mage::getModel('pointofsale/pointofsale')->getPlaces(); } if (Mage::getModel('advancedinventory/advancedinventory')->getLocalGlobalStockByProductId($row->getId())->getManageLocalStock()) { $html = (int) 0; foreach ($places as $p) { $data = Mage::getModel('advancedinventory/advancedinventory')->getLocalStockQty($row->getId(), $p->getPlaceId()); $html += $data["quantity_in_stock"]; } } else { $html = "-"; } } else { $html = "-"; } return (string) $html; }
public function render(Varien_Object $row) { $permissions = Mage::helper('advancedinventory/permissions')->getUserPermissions(); $all = $permissions->isAdmin(); $manage_stock = Mage::getStoreConfig("cataloginventory/item_options/manage_stock"); if ($row->getManageStock() || $row->getUse_config_manage_stock() && $manage_stock) { if (in_array($row->getTypeId(), array('simple', 'virtual', 'downloadable'))) { $actions[] = array('url' => "javascript:InventoryManager.saveStocks('" . $this->getUrl('*/*/save', array('id' => $row->getId(), "is_admin" => (int) $all, "store_id" => Mage::app()->getRequest()->getParam('store', 0))) . "','" . $row->getId() . "')", 'caption' => Mage::helper('advancedinventory')->__('Save change'), 'id' => 'save'); if ($all) { if (Mage::getModel('pointofsale/pointofsale')->getPlaces()->count()) { if (Mage::app()->getRequest()->getParam('store') == Mage_Core_Model_App::ADMIN_STORE_ID) { $actions[] = array('caption' => Mage::helper('advancedinventory')->__(!$row->getMultistock_enabled() ? Mage::helper('advancedinventory')->__("Enable multi-stock") : Mage::helper('advancedinventory')->__("Disable multi-stock")), 'url' => "javascript:InventoryManager.enableMultiStock('grid'," . $row->getId() . ")", 'id' => 'enable'); } } } } } if ($all) { $actions[] = array('url' => $this->getUrl('adminhtml/catalog_product/edit', array('id' => $row->getId(), "tab" => "product_info_tabs_inventory")), 'caption' => Mage::helper('advancedinventory')->__('Edit product'), 'popup' => true, 'id' => 'edit'); } $this->getColumn()->setActions($actions); return parent::render($row); }
/** * Check whether the attribute is Applicable to the object * * @param Varien_Object $object * @param Mage_Catalog_Model_Resource_Eav_Attribute $attribute * @return boolean */ protected function _isApplicableAttribute($object, $attribute) { $applyTo = $attribute->getApplyTo(); return count($applyTo) == 0 || in_array($object->getTypeId(), $applyTo); }
/** * Returns whether this qty field must be inactive * * @param Varien_Object $row * @return bool */ protected function _isInactive($row) { return $row->getTypeId() == Mage_Catalog_Model_Product_Type_Grouped::TYPE_CODE; }