vpietri / adm_warehouse Goto Github PK
View Code? Open in Web Editor NEWMulti stock extension for Magento
Multi stock extension for Magento
It looks like you forgot to commit the adm/warehouse.xml layout file?
I'm currently evaluating your extension, the idea seems great but the extension seems rushed and slapped together. When I first installed the extension, I tried adding a new Warehouse to test multiple inventory/stock, but got redirected to a 404 page. See below for the fixes.
Is this extension still in development? Are you using it on any Magento installation or testing it locally?
Add this controller action which redirects to the edit action.
public function newAction()
{
$this->_forward('edit');
}
When you register the model in the registry, it needs to be outside the if
statement. Reason being the form references this object whether it has data or not.
if ($id) {
// Load record
$model->load($id);
// Check if record is loaded
if (!$model->getId()) {
Mage::getSingleton('adminhtml/session')->addError($this->__('This stock no longer exists.'));
$this->_redirect('*/*/');
return;
}
}
Mage::register('current_stock', $model);
Because you have chosen to inject (override) the product inventory tab using an observer (using XML layout updates would be better) for both new and edit actions, an error is thrown when creating a new product
A quick fix to this problem is shown below.
You can simply replace the getQtysByWarehouse()
function with what I've written below.
public function getQtysByWarehouse()
{
if (!$this->_item_by_warehouses instanceof ADM_Warehouse_Model_CatalogInventory_Resource_Stock_Collection)
{
$warehouses = Mage::getModel('cataloginventory/stock')->getCollection();
if ($stockItem = $this->getStockItem())
{
foreach ($warehouses as $warehouse)
{
foreach ($stockItem->getStockDetails() as $stockDetail)
{
if ($stockDetail['stock_id'] == $warehouse->getId())
{
$warehouse->setQty($stockDetail['qty']);
$warehouse->setItemId($stockDetail['item_id']);
}
}
}
}
$this->_item_by_warehouses = $warehouses;
}
return $this->_item_by_warehouses;
}
All I've done is check that a stock item can be retrieved, and skip trying to set stock details for each warehouse if it cannot. The reason for the error was due to trying to retrieve the stock item from the product, when the product hadn't even been created yet.
Hi Vincent,
Any future plan to upgrade this extension to Magento 2.* !!
Best regards
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.