7
votes
Accepted
I want to set custom price programmatically to the product Magento 2
Try the following code to update price
foreach ($products_array as $value) {
$params['qty'] = 1;//product quantity
$_product = $this->productRepository->getById($value);
...
5
votes
Accepted
Why is there a base_row_total variable in Quote and Order models?
Magento has the ability to calculate currencies based on a conversion rate from store to store. Your base store may be in USD, but you also sell in the UK so you accept GBP.
The base_row_total is ...
5
votes
I want to set custom price programmatically to the product Magento 2
You can achieve this with the observer.
First create events.xml file in folder ‘test/Hello/etc/frontend’ and use event ‘checkout_cart_product_add_after’.
<?xml version="1.0"?>
<config xmlns:...
4
votes
When Quote id generated in magento?
The quote id is generated when a product is added to cart.
Here's the workflow:
app/code/core/Magento/Checkout/controllers/CartController.php => addAction() method
$cart = $this->_getCart();
.....
4
votes
Accepted
Getting Value of product attribute on cart page even not assigned to that particular product Magento 2
Becuase you use same object every time in foreach. YOu need to create new object in foreach loop. So you final code look like this:
$objectManager = \Magento\Framework\App\ObjectManager::getInstance()...
3
votes
Accepted
convert quote to order for guest users
Try following way:
$quoteObj = Mage::getModel('sales/quote')->load(706);
$items = $quoteObj->getAllItems();
$quoteObj->reserveOrderId();
//print_r($items);
$addressData = array(
'firstname' => '...
3
votes
Create Duplicate quote item instead of updating existing quote item for same product
To change what's getting added to the cart you need to observe an event before the quote item is created. This way you can choose to update the qty of an existing item, add one or more new items, or ...
3
votes
Accepted
Get Quote ID from an Order ID or Order Number SQL?
There are only one relation between Magento quote item tables & sales order tables and that is sales_flat_order.quote_id=sales_flat_quote_item.quote_id.
In magento,...
3
votes
Accepted
Get quotes (active and inactive) for a customer
$quote_collection = Mage::getResourceModel('sales/quote_collection')
->addFieldToSelect('entity_id')
->addFieldToSelect('subtotal')
->addFieldToFilter('customer_id', 5)...
2
votes
Accepted
Magento programatically convert quote to order - orders missing in backend
Ok, I figured this out myself.
The not registered order in Magento Backend even if PayPal captured the payment was due to an extension that returned an error after redirection to success page. If ...
2
votes
Accepted
save custom field from sales_flat_order_item to sales_flat_order
You'll need to decide whether you want that information at the entire order level or at the order line-item level.
Both these tables, sales_flat_order_item and sales_flat_order, serve different ...
2
votes
Programmatically assign customer to a quote
A quote is actually a 'cart' object.
A customer can have many quotes. One for each website.
the quote object is not created when the customer is created. It is created when the customer adds the first ...
2
votes
How to change product name in quote item dynamically
Take a look at Magento change product name adding to cart
Use event sales_quote_item_set_product
class Mynamespace_Samples_Model_Observer
{
public function salesQuoteItemSetProduct(...
2
votes
Change registered customer biliing email address on the time of checkout
$quote->getCustomer() retrieved the customer model. The email address for the order / quote is stored in the billing address object and in the quote object.
$quote->getBillingAddress()->...
2
votes
Accepted
get product id from quote id - Magento 1.9
Use below code
$quoteId=784;
$quote = Mage::getModel('sales/quote')->load($quoteId);
$cartItems = $quote->getAllVisibleItems();
foreach ($cartItems as $item) {
$productId = $item->...
2
votes
Remove SalesRule from Quote Magento 1.x
I figured it out myself although I am not sure how efficient this answer is.
As previously mentioned the code is executing in the
salesrule_validator_process
this event pass following data with ...
2
votes
Update "sales_flat_order_item" table when making an order
Managed to get last item id with this solution. I know, it isn't the most efficient way but still
public function orderPlaceAfter($observer)
{
$order = $observer->getEvent()->getOrder();
...
2
votes
Accepted
Magento 1: Check if customer has quote
You can filter that table with its corresponding collection model:
$quote = Mage::getResourceModel('sales/quote_collection')
->addAttributeToFilter('customer_id', $customer->getId())
...
2
votes
Accepted
Show value of all totals in controller action
This should work:
$quote = Mage::getModel('checkout/session')->getQuote();
$address = $quote->getShippingAddress();
$quoteData = $quote->getData(); //getData() is not necessary, you could ...
2
votes
Getting Value of product attribute on cart page even not assigned to that particular product Magento 2
Please Try something like this
....
function productData($pro_id)
{
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$product_object = $objectManager->create(...
1
vote
Accepted
Magento 1: when is the email added to the quote?
Email address is added to the quote in conjunction with the billing address. On standard checkout, this is step 1 (or 2, after login/register) of the checkout process.
If a customer completes that ...
1
vote
Magento 2 saving custom attribute to sales_order_items
You need to create custom order attribute for it. And then programmatically assign value for it.
You can follow given thread to create order attribute.
Magento 2 How to create new order attribute ...
1
vote
Accepted
Get quote data(Shipping zip code) from observer magento 2
First of all, you can not get order object $order from this observer.
This observer only able to give u Quote Object mean Cart object
$this->eventManager->dispatch(
'...
1
vote
How to add new input field in cart page in magento2?
You have bellow a more links for new custom field in cart page.
How To Add Additional Options In Magento 2 Cart
How do I add a custom field to the cart in magento 2?
1
vote
Magento2 Split Order Based on Vendor
First, You should not use the ObjectManager $product = $objectManager->get('Magento\Catalog\Model\Product')->load($product_id); directly!
https://magento.stackexchange.com/a/117103/69
Also, it ...
1
vote
Magento model not fetching data
I dont know why you use method2 b'cuz method 1 is right
$quote_address = Mage::getModel('sales/quote_address')->getCollection();
$quote_address->addFieldToFilter("address_type", array("eq" =&...
1
vote
Accepted
Remove item from Quote item - Magento1.9
try below code because save method doesnot work with collection
$quote = Mage::getModel('sales/quote')->load(quote_id);
// get item id by your logic
$quote->removeItem($itemId);
$quote->...
1
vote
Magento 1.9 Not able to create quote item
to find if particular product is in quote
if (! $quote->hasProductId($product_id)) {
// Product is not in quote so add your logic
}
else
{
$item = $quote->getItemByProduct($product_id);
...
1
vote
get cart items from custom column value
You can try the below code:
$deviceId=802;
$collection = Mage::getModel('sales/quote_item')->setStoreId(1)->getCollection()->addFieldToFilter('device_id', array('eq' => $deviceId));
...
1
vote
get cart items from custom column value
you can do, try below code tested by me
$deviceId=802; //if your value in ales_flat_quote table
$quote = Mage::getModel('sales/quote')->load($deviceId,'device_id');//here device_id is feild in ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
sales-quote × 74magento-1.9 × 34
sales-order × 22
quote × 20
magento2 × 17
event-observer × 9
quoteitem × 9
orders × 8
cart × 8
addtocart × 7
sales × 7
database × 6
checkout × 4
magento-2.1 × 3
customer × 3
shipping × 3
products × 3
custom-attributes × 3
magento2.3 × 2
magento-1.7 × 2
magento2.2 × 2
magento-1 × 2
magento-enterprise × 2
onepage-checkout × 2
product × 1