I'm hoping someone will be able to solve an issue that takes us a lot of manual labour, the solution seems simple :-)
Summary:
Is it possible to change the code that, when you Edit an order (invoiced or not yet invoiced) that is does not take the Order Date and Time of when you edited the order, but it uses the Order Date and Time of the original order?
Example:
Order 1000 was placed on 15/05/2015 at 12:00
Order 1000 was edited on 25/05/2015 at 14:00, the new order ID is 1000-1
We will credit or cancel order 1000, depending on the invoice state
Standard Magento will give order 1000-1 the Order date of 25/05/2015 14:00
But we would like order 1000-1 to receive the order date of 15/05/2015 12:00, the same as original order 1000.
Explanation:
We use a Magento Extension (Embedded ERP) which uses product reservations. If a customer orders a product, it does not remove the item from stock, but reserves stock. If the item is on backorder, the customer is placed in queue.
The system uses a first in, first out system. It uses the order date to check which customer is higher in queue than the other customers.
Because we use backorders, customer sometimes like to add or remove items to order, because they have to wait for items anyway. But when changing an order to add or remove items, the new order gets a new Order Date and Time. We want the customer to have the same product reservations as their original order. So now we manually change the product reservation of each item so it's the same as their original order.
I expect we can have the correct product reservations on the new order done automatically when the new order has the same order date and time of the original order.
Copy the file app/code/core/Mage/Adminhtml/Model/Sales/Order/Create.php into app/code/local/Mage/Adminhtml/Model/Sales/Order/. Keep the folder structure unchanged!
Find the option createOrder() and change this
if ($this->getSession()->getOrder()->getId()) {
$oldOrder = $this->getSession()->getOrder();
$this->getSession()->getOrder()->setRelationChildId($order->getId());
$this->getSession()->getOrder()->setRelationChildRealId($order->getIncrementId());
$this->getSession()->getOrder()->cancel()
->save();
$order->save();
}
with this:
if ($this->getSession()->getOrder()->getId()) {
$oldOrder = $this->getSession()->getOrder();
$this->getSession()->getOrder()->setRelationChildId($order->getId());
$this->getSession()->getOrder()->setRelationChildRealId($order->getIncrementId());
$this->getSession()->getOrder()->cancel()
->save();
$order->setCreatedAt($oldOrder->getCreatedAt());
$order->save();
}
Related
Trying to remove an item from the quote object, but cannot get order total updated.
For example, a customer adds product A ($2), and B ($3) to the cart, and then place the order.
After customer hits the place order button, I am trying to remove product B from the order.
Using the code below, I can successfully remove B from the order. But the total of the order is not updated.
$quote->getItemsCollection()->removeItemByKey($item->getId());
Say I have product B removed, then order should have a total of $2, but I checked from the order grid in backend, the total was $5.
//Try with the below code. not tested.
$quote->getItemsCollection()->removeItemByKey($item->getId());
$quote->save();
//I thing you need to remove items from order to reflect your changes in order.
foreach($order->getAllItems() as $item) {
$item->isDeleted(true);
}
Please note that this is not recommended to do things like this as per this link More details
I need help.
I am new to obiee (recently moved from business objects and re-creating all reports in obiee).
Here is an example I need help with. I have created an analysis where I am listing all orders with their target delivery dates and number of products in each order.
Order Id......Target Delivery Date...No of products
Abc....1/1/2016.....5
I want to add to a column next to No of products called "No of prods delivered on time". I want to compare delivery date of each product within a order with the target delivery date and
Give count of products delivered within the target date.. So the output should be
Abc....1/1/2016....5.....3
Where 3 is number of products delivered on time.
I could do it in BO by running two queries and merging them however in obiee I am not able to add second query to my analysis. I did try at product level using case when target date >=delivery date then 1 else 0 and wrapped this with sum function to aggregate but it didn't work ..
Appreciate your help in this. Searching for this topics give me results for running queries from multiple subject area :(
You also have unions in OBIEE, you union the results of 2 queries which return the same structure, so you have query A with Order ID, Target Date, No Products and a Dummy column with a 0 and default agregation Sum, and a second query with Order ID, Target Date, Dummy column summing 0 and the number of products delivered.
You do all this in the criteria tab of the analysis. It's important the order in which you put your columns, because that's what OBIEE is using to do the union.
Regards
I'm stuck and confused and hopefully can get some help here. I have a query that pulls info from two tables and a report that reads it. My two tables are as such: One of the is a Contact list with phone numbers, names, and addresses. The other table is a paid history. The PhoneNumber field is how they're tied together. There are no duplicate entries in the Contact table but there are multiple paid instances per phone number in the other table.
My report groups them on the phone number, but I also need it to sort by date. My date field is marked as time/date, and it is in the paid table. The issue I'm running into is that I can either Group on PhoneNumber OR sort on the Date field but not both. When I set the Group as the top level, it ignores the Sort that I have set below it. If I take the sort and drag it up so that it becomes the top level, it won't group. When it doesn't group I'm left with multiple instances of the same Contact info... as in I get a new listing for every date that it has ever paid, whereas I need one a single Contact listing with each paid instance to be grouped underneath it.
Here's my query SQL:
SELECT
tblContributorsLead.FirstName,
tblContributorsLead.LastName,
tblContributorsLead.Address1,
tblContributorsLead.ZipCode,
tblContributorsLead.CityName,
tblPledgesLead.PledgeAmountRecd,
tblPledgesLead.DateRecd,
tblPledgesLead.PhoneNumber,
tblPledgesLead.DispositionTime,
tblPledgesLead.Agent,
tblPledgesLead.CampaignName,
tblPledgesLead.Custom20
FROM
tblContributorsLead
INNER JOIN
tblPledgesLead
ON tblContributorsLead.PhoneNumber = tblPledgesLead.PhoneNumber
WHERE
(((tblPledgesLead.PledgeAmountRecd)>0)
AND ((tblPledgesLead.DateRecd) Is Not Null));
Why would I only be able to either group OR sort but not both at the same time?
Edit: http://icloudbackups.com/stripped.zip is a copy of my database stripped down.
I think I understand now what you wanted - to have the phone number groups with the most recent dates show up at the top. To do this you need to identify the Last (or First if you need it the other way around) DateRecd for each PhoneNumber.
SELECT SortingAndGrouping.LastDate, SortingAndGrouping.PhoneNumber, tblPledgesLead.DateRecd
FROM (tblContributorsLead INNER JOIN tblPledgesLead ON
tblContributorsLead.PhoneNumber = tblPledgesLead.PhoneNumber) INNER JOIN
(SELECT CDate(Format(tblPledgesLead.DateRecd,"MM/DD/YYYY")) As LastDate, tblPledgesLead.PhoneNumber
FROM tblContributorsLead INNER JOIN tblPledgesLead ON
tblContributorsLead.PhoneNumber = tblPledgesLead.PhoneNumber
ORDER BY tblPledgesLead.DateRecd DESC) AS SortingAndGrouping ON
tblContributorsLead.PhoneNumber = SortingAndGrouping.PhoneNumber
ORDER BY SortingAndGrouping.LastDate DESC , SortingAndGrouping.PhoneNumber, tblPledgesLead.DateRecd DESC;
You will need to add the additional fields you want to display (I removed them here for clarity), and have the report enforce the same sorting I have here - Create a group for the LastDate column, then a group for the PhoneNumber column, then have the sorting specified.
When customer places an order, how to set minimum order amount?
i.e) Total amount of order not below than $500.
I know how to get total order amount. But I don't know where to place that code and where to check
sOrderId = Mage::getSingleton('checkout/session')->getLastOrderId();
$oOrder = Mage::getModel('sales/order')->load($sOrderId);
if($oOrder >=$500)
{
.....
}
If customer has purchased total less than $500, they won't allow to checkout at the cart.
Login as admin, then go to System->configuration, then select ‘Sales‘ from left Nav and click on ‘Minimum order amount‘.
Then select Yes from Enable dropdown, enter Minimum order amount, enter message and also enter error message that will be shown whenever the order will be less than specified amount at the shopping cart.
Thanks.
You need to change the scope of the minimum amount setting. For that you need a new module with a system.xml file that contains the same path to the minimum amount field and just changes the <show_in_store> value. Read more about this here.
How do I customise the starting number for orders, invoices etc in Magento 1.5?
From magento's forum:
by LindyKyaw (Magento Team Member), changing start number (through sql query):
There is a table in the database which stored increment id of order.
It is called “eav_entity_store” table.
You can check which entity type id belongs to which entity by looking at
eav_entity_type table.
You can run following query to update last increment id for the order.
update eav_entity_store
inner join eav_entity_type on eav_entity_type.entity_type_id = eav_entity_store.entity_type_id
set eav_entity_store.increment_last_id=3001
where eav_entity_type.entity_type_code='order';
by FOOMAN (active contributor), changing start number (through db management tool) and removing "0"s at the beginning:
With a tool like phpmyadmin look at your database. In the table
eav_entity_type you will find all entity types listed. The one of interest to
change where the order number starts is order sales/order. Remember the
entity_type_id (in my install it is 11). To remove the leading zeros
(padding) set increment_pad_length to 1.
Next go to the table eav_entity_store. Look up the entity_type_id. Now you
can change the value of increment_prefix and increment_last_id. If you wanted to
have your next orderId to be 15000 set increment_last_id to 14999 and
increment_prefix to 0.
Additionally you need to make a copy of this file
/app/code/core/Mage/Eav/Model/Entity/Increment/Abstract.php
to
/app/code/local/Mage/Eav/Model/Entity/Increment/Abstract.php
public function getPadLength()
{
$padLength = $this->getData('pad_length');
if (empty($padLength)) {
$padLength = 0;
}
return $padLength;
}
...
public function format($id)
{
$result= str_pad((string)$id, $this->getPadLength(), $this->getPadChar(), STR_PAD_LEFT);
return $result;
} Hope That Helps
Actually with the newer versions (and probably in 1.5 as well), there is an easier way to change it. In PHPMyAdmin, or your mysql client, go to the eav_entity_type table. Locate the table in the entity_type_code column (probably order), and set the increment_pad_length to be whatever you would like, as well as the increment_pad_char.
Then you don't have to rewrite core code - a win-win.
JMax
Magento Order No
It's simple....
go to phpmyadmin
select your datbase and then select the table "eav_entity_store"
in this table, change the increment_last_id (for example, I have set 3456767 in my table)
after that I create a new order. Now my orders start from the number 346768
There is actually a good extension for accomplish this task.
It allows you to customize the order ID in a lot of different way:
for example you can use a combination of:
number like year,month,,day,hr,sec,
use a custom counter (you can decide the starting number )
a combination of all above methods
add some custom string in any position of the order ID
This is the ext. on Magento connect:
http://www.magentocommerce.com/magento-connect/custom-order-id-8210.html
I personally tried it and it very good ( works fine with all my payment methods and I had no issue at all )