This is the blog for getting Idea regarding PHP, Magento, jQuery and JavaScript for Customization.

Monday 11 April 2016

Magento : Add last increment id of "sales_flat_quote_item" in another table

Magento
        $production = Mage::getSingleton('core/session')->getproValue($production); /* This is the session value which is set on Category/List page */
        $shipping = Mage::getSingleton('core/session')->getshipValue($ship);  /* This is the session value which is set on Category/List page */

/* This is code for Change Row Data of the product in cart and add Shipping charge in to that product into cart
         * Changes By Rixit
        // */
       
            $connection = Mage::getSingleton('core/resource')
            ->getConnection('core_read');
            $select = $connection->select()
            ->from('sales_flat_quote_item', array('MAX(item_id) as itn')); // select * from tablename or use array('id','name') selected values  
            $rowsArray = $connection->fetchAll($select); // return all rows
            $rowArray =$connection->fetchRow($select);   //return row
       
            $temp = $rowArray['itn'];
           
            $select1 = $connection->select()
            ->from('sales_flate_lastinsertd_id', array('MAX(last_inserted_id) as itn1')); // select * from tablename or use array('id','name') selected values  
            $rowsArray = $connection->fetchAll($select1); // return all rows
            $rowArray =$connection->fetchRow($select1);   //return row
       
            $itnew = $rowArray['itn1'];
       
            if( ($temp != $itnew) && ($temp >= $itnew) )
            {   
                $total = $production + $shipping;
       
                $connection = Mage::getSingleton('core/resource')
                ->getConnection('core_write');
       
                $connection->beginTransaction();
                $fields = array();
                $fields['last_inserted_id']= $temp;
                $fields['production_time']= $production;
                $fields['shipping_time']= $shipping;        
                $fields['total']= $total;        
                $connection->insert('sales_flate_lastinsertd_id', $fields);
                $connection->commit();
                               
            }
            else
            {
                //echo "Riisdfs";
            }
           
        /*
         * End of Changes By Rixit
        // */

No comments:

Post a Comment