Skip to main content
8 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); ...
Priyank's user avatar
  • 7,702
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:...
Prakash Patel's user avatar
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(); .....
Raphael at Digital Pianism's user avatar
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()...
Prince Patel's user avatar
  • 22.8k
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' => '...
Sohel Rana's user avatar
  • 35.9k
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->...
Prashant Valanda's user avatar
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(); ...
Sergiu Turus's user avatar
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 ...
Capri82's user avatar
  • 213
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 ...
hardik's user avatar
  • 496
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()) ...
EssGee's user avatar
  • 338
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(...
Divyarajsinh Dodiya's user avatar
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 ...
Ryan Hoerr's user avatar
  • 12.3k
1 vote
Accepted

Get Payment details in QuoteManagement.php

I have solved by below code snap not sure that this the correct way or not. $paymentDetails = $paymentCardDetails = ''; $postData = file_get_contents("php://input");//Get all param ...
Pushpendra Singh's user avatar
1 vote
Accepted

Which tables are affected in Magento 1.9 when I empty the cart?

When you add product to the cart, magento will have entries in sales_flat_quote,sales_flat_quote_item and sales_flat_quote_address ie: Carts are saved to the sales_flat_quote table The items in the ...
NID's user avatar
  • 937
1 vote

Is there an event or plugin spot for when cart rule is no longer valid?

The salesrule_validator_process event that you mentioned is a good start. You can observe this event and check if the applied rule is still valid. You may need to inspect the coupon code and its ...
Divyarajsinh Barad's user avatar
1 vote

Is there an event or plugin spot for when cart rule is no longer valid?

The first event you might want to try is salesrule_validator_process. This event is dispatched by the process() method of the Magento\SalesRule\Model\Validator class, which is responsible for applying ...
junaidh's user avatar
  • 63
1 vote

Is there an event or plugin spot for when cart rule is no longer valid?

I would try to write an around plugin on the function \Magento\SalesRule\Model\Quote\Discount::collect When the coupon is already set and the total in the cart do show discount amount and the coupon ...
Herve Tribouilloy's user avatar
1 vote

Is there an event or plugin spot for when cart rule is no longer valid?

I would do it with an around plugin for \Magento\SalesRule\Model\RulesApplier::applyRules There you have $rules parameter which would be an array containing old applied rule ids, and result of $...
Sinisa Colic's user avatar
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 ...
Kishan Patadia's user avatar
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( '...
Amit Bera's user avatar
  • 77.6k
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?
St3phan's user avatar
  • 2,907
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 ...
B00MER's user avatar
  • 8,307
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" =&...
Murtuza Zabuawala's user avatar
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->...
Murtuza Zabuawala's user avatar
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); ...
Gopal Patel's user avatar
  • 3,139
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)); ...
Prasanta Hatui's user avatar
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 ...
Murtuza Zabuawala's user avatar
1 vote

How to add quote Item id as new field?

I have a solution here for Magento 2. I am sharing this for basic Idea. You can create an observer in 1.9 for sales_model_service_quote_submit_after in your XML file. <events> <...
Pankaj Sharma's user avatar
1 vote
Accepted

How to add quote Item id as new field?

Beste way i think is creating a observer on the sales_model_service_quote_submit_after action and there manipulate the database to process the data needed. hope this helps. In config.xml <...
Kay Int Veen's user avatar
  • 1,503
1 vote
Accepted

Event for Sales Order Quote Item

The event exists, but this seems wrong ... <adminhtml> <models> <MyTest_Quote> <class>MyTest_Quote_Model_Observer</class> </...
sv3n's user avatar
  • 11.7k

Only top scored, non community-wiki answers of a minimum length are eligible