#StackBounty: #magento2 #magento-1.9 Magento Community Edition 1.9 End of life

Bounty: 50

Our current platform, Magento Community Edition 1.9, is slated to receive security patches until June of 2020, according to the documentation on Magento’s website

https://magento.com/blog/magento-news/supporting-magento-1-through-june-2020
https://magento.com/sites/default/files/magento-open-source-software-maintenance-policy.pdf

I have heard from alternate sources that Magento CE 1.9 will only be supported until October of this year (though I find that highly suspect). Secondly, what would a transition to a Magento Open Source 2.x version look like down the road when 1.9 eventually reaches end of support?


Get this bounty!!!

#StackBounty: #magento2 #magento-1.9 #database #orders SQL to get order items straight from the database?

Bounty: 100

How do we get a list of order items and their data (name, sku, quantity, price, weight, and dimensions)? Without using Magento’s own framework components.

The problem is that if a product contains options it appears multiple times in the table by different product types (simple, bundle, configurable, etc.) and different product ids.

$items = array();

$sql = (
  "SELECT oi.name, oi.sku, oi.qty_ordered, oi.price, oi.weight
  FROM {$db->prefix}sales_flat_order_item oi
  WHERE oi.order_id = ". (int)$order_entity_id .";"
);

if ($result = $mysqli->query($sql)) {

  while ($row = $result->fetch_assoc()) {

    $items[] = [
      'name'                   => $row['name'],
      'sku'                    => $row['sku'],
      'quantity'               => (float)$row['qty_ordered'],
      'unit_price'             => (float)$row['price'],
      'unit_weight'            => (float)$row['weight'],
      //'unit_length'            => (float)$row['length'], // Not present?
      //'unit_width'             => (float)$row['width'], // Not present?
      //'unit_height'            => (float)$row['height'], // Not present?
    ];
  }

  $result->close();
}

If I pass a filter AND product_type = 'simple' to get only the simple products, they do not contain price.


Get this bounty!!!

#StackBounty: #magento-1.9 #php Magento add position 999 when assign product to category

Bounty: 50

I’m using Magento 1.9.x and trying to change default position number of products.

Ex, when we assign product to category via product page i need to set it to 999 position

enter image description here

I changed default position field value of catalog_category_product table

enter image description here

But nothing changed.

i changed magentoappcodecoreMageCatalogModelResourceCategory.php

/**
         * Add products to category
         */
        if (!empty($insert)) {
            $data = array();
            foreach ($insert as $productId => $position) {
                $data[] = array(
                    'category_id' => (int)$id,
                    'product_id'  => (int)$productId,
                    'position'    =>  (int)$position ? (int)$position : 999
                );
            }
            //(int)$position
            $adapter->insertMultiple($this->_categoryProductTable, $data);
        }

but it only effect when adding products to category via category page.

anyone know a solution for this please, Thank You


Get this bounty!!!

#StackBounty: #magento-1.9 #soap #soap-api-v1 Products show only in admin when adding via Magento 1.9 Custom Wishlist SOAP API

Bounty: 50

Requirement: I am a newbie in magento trying to make a custom SOAP API in Magento 1.9 for managing wishlist. I need to connect it to an android application being developed in ionic V1.
At first i tried to use this extension magento-api but could not find a way to maintain session information in android. So, i moved to developing my own API.
I am able to fetch wishlist information(wishlist_id, items etc) and add to it.

Issue: But after adding a product in the wishlist via soap call, it is only shown in the admin area for the customer and not on the front-end of the website(User is logged in). Only products added from front-end(browser) are shown on front-end wishlist page.

After comparing the functionality from the front-end(/app/code/core/Mage/Wishlist/controllers/IndexController.php) with my Api.php(shown below) seems like my $buyRequest variable is missing some ‘form-key’ but i do not understand magento too much to understand this.

I have added the Api.php at /app/code/core/Mage/Wishlist/ModelApi.php.

My code to add product to wishlist is as follows:

public function create($customer_id, $product_id, $store = null){
    $return_result = array(
        'code' => 0,
        'msg' => null,
        'model' => null,
        'customer_id' => $customer_id,
        'product_id' => $product_id
    );
    $buyRequest = new Varien_Object(array());
    $params = array('product' => $product_id,
            'qty' => 1,
            'store_id' => $store,
            );
    $buyRequest->setData($params);

    $wishlist = Mage::getModel('wishlist/wishlist')->loadByCustomer($customer_id, true);
    $product = Mage::getModel('catalog/product')->load($product_id);
    $result = $wishlist->addNewItem($product, $buyRequest);

    Mage::helper('wishlist')->calculate();
    if($result){
        $return_result['msg'] = 'Product '.$product_id.' Added ';
        $return_result['model'] = $result;
    }  
    return json_encode($return_result);
}

I used the following link to implement the add functionality and used some code in the from the /app/code/core/Mage/Wishlist/controllers/IndexController.php file: add catalog product in wishlist programmatically in magento

Any help would be appreciated.


Get this bounty!!!

#StackBounty: #magento-1.9 #onestepcheckout #customer-session #sagepay Customer logged out after checkout & redirected to empty sho…

Bounty: 250

I’m trying to find out why some logged in customers are being logged out of their accounts and redirected to an empty shopping cart after clicking the place order button in Magento.

I am using SagePay 4.1.3 and Idev_OnstepCheckout

I’ve been looking into the saveAfter event in sagePay to see where the session is terminated but I am not able to locate the function call but I can see where the failedPayment.log is called.

public function saveAfter($o)
{
    $order = $o->getEvent()->getOrder();

    $isSage = Mage::helper('sagepaysuite')->isSagePayMethod($order->getPayment()->getMethod());

    if (!$order->getId() || $isSage === false || $order->getIsRecurring()) {
        return $o;
    }

    $dbtrn = $this->_getTransactionsModel()->loadByParent($order->getId());

    if ($dbtrn->getId()) {
        return $o;
    }

    $rqVendorTxCode = Mage::app()->getRequest()->getParam('vtxc');
    $sessionVendor = ($rqVendorTxCode) ? $rqVendorTxCode : $this->getSession()->getLastVendorTxCode();

    if($sessionVendor == null){
        $sessionVendor = Mage::app()->getRequest()->getParam('VendorTxCode');
    }

    /**
     * Multishipping vendors
     */
    $multiShippingTxCodes = Mage::registry('sagepaysuite_ms_txcodes');
    if ($multiShippingTxCodes) {

        Mage::unregister('sagepaysuite_ms_txcodes');

        $sessionVendor = current($multiShippingTxCodes);

        array_shift($multiShippingTxCodes);
        reset($multiShippingTxCodes);

        Mage::register('sagepaysuite_ms_txcodes', $multiShippingTxCodes);
    }
    /**
     * Multishipping vendors
     */

    $reg = Mage::registry('Ebizmarts_SagePaySuite_Model_Api_Payment::recoverTransaction');
    if (!is_null($reg)) {
        $sessionVendor = $reg;
    }

    if (is_null($sessionVendor)) {


        if (!$dbtrn->getId()) {

            #For empty payments or old orders (standalone payment methods).
            if ((Mage::app()->getRequest()->getControllerModule() == 'Mage_Api') || Mage::registry('current_shipment') || Mage::registry('sales_order') || Mage::registry('current_creditmemo') || Mage::registry('current_invoice') || ($order->getPayment()->getMethod() == 'sagepayrepeat')) {
                return $o;
            }

            $logfileName = $order->getIncrementId() . '-' . time() . '_Payment_Failed.log';

            $request_data = $_REQUEST;
            if (isset($request_data['payment'])) {
                $request_data['payment']['cc_number'] = 'XXXXXXXXXXXXX';
                $request_data['payment']['cc_cid'] = 'XXX';
            }

            Sage_Log::log($order->getIncrementId(), null, $logfileName);
            Sage_Log::log(Mage::helper('core/http')->getHttpUserAgent(false), null, $logfileName);
            Sage_Log::log(print_r($request_data, true), null, $logfileName);
            Sage_Log::log('--------------------', null, $logfileName);

            Mage::throwException('Payment has failed, please reload checkout page and try again. Your card has not been charged.');
        }

        return $o;
    }

Has anyone seen this problem before and know roughly how to resolve it?

Any ideas will be welcomed.


Get this bounty!!!

#StackBounty: #magento-1.9 #composer How to load a classmap[ped] Composer class (packagist) in Magento 1?

Bounty: 50

I’ve installed and deployed magento-hackathon/magento-composer-installer in my Magento 1.9 and I am trying to add and use mpdf/mpdf (composer packagist) in a controller.

This package contains a classmapped file

"autoload": {
    "classmap": [
      "filters/",
      "fpdi.php",
      "fpdf_tpl.php",
      "fpdi_pdf_parser.php",
      "pdf_context.php"
    ]
  },

Which is called in another component.

$this->parsers[$fn] = new fpdi_pdf_parser($fn);

And then Magento gives me the error

Warning: include(Fpdi/Pdf/Parser.php): failed to open stream: No such
file or directory in
/../mymagento/lib/Varien/Autoload.php on line 94

The Mage.php seems to be patched properly, and I also tried to do composer dumpautoload.

Some facts and findings:

  • If I create a /newfile.php (on the root folder, with not triggering Magento), include autoload.php, and call the method, it works.
  • If I disable developer mode it works (and the warning is logged).
  • If I change the Varien/Autoload.php and add an if(stream_resolve_include_path($classFile)) (as suggested here) before returning the include, it works (but I would override a core file).
  • It seems that when composer autoload resolves fpdi_pdf_parser it makes a require_once to ‘pdf_parser.php‘ and at this stage Mage autoload is triggered instead of Composer’s autoload.

Am I missing something? Any help is appreciated.


Get this bounty!!!

#StackBounty: #magento-1.9 #multistore #multicurrency #multi-website What is best approach to create 100+ stores in Magento?

Bounty: 50

Magento CE 1.9.x
Assume the case that we need to create 100+ stores having 10k products in each store.

  1. each store will have 100+ products.
  2. there are very high chances that each store can have their own root categories.
  3. some products can be unavailable in certain stores.
  4. language can vary across two stores (within the same Magento instance)
  5. currency may also vary if between two stores.
  6. product quantity may also vary between two stores and price too.

In this approach what will be the best method to be used?

  1. create a separate website for each 100+ stores (i.e 100 stores + 100 website + 100 store view )
  2. keep one main domain (website) and create 100+ stores and stores view. (i.e 100 stores + 1 website + 100 store view )

I heard that creating multiple websites may cause system performance issues. Please advice if this is true.


Get this bounty!!!

#StackBounty: #magento-1.9 Extra fee doesn't show at the admin panel orders

Bounty: 50

I added an extra fee. It’s working well at the checkout. enter image description here

But at the admin panel -> sales -> orders -> my order it doesn’t show.
enter image description here

But price is well.
At the invoice too

enter image description here

How can I show it?
I tried :

<fieldsets>
     <sales_convert_quote_address>
         <insurance><to_order>*</to_order></insurance>
         <insurance><to_order>*</to_order></insurance>
         <insurance><to_invoice_item>*</to_invoice_item></insurance>
     </sales_convert_quote_address>
</fieldsets>

But it doesn’t help. Thanks advance.

EDIT:

class Cart_InsuranceUpsell_Model_Paymentinsurance extends Mage_Sales_Model_Quote_Address_Total_Abstract
{
    protected $_code = 'Insurance Upsell';

    public function collect(Mage_Sales_Model_Quote_Address $address)
    {
        if (Mage::getSingleton('checkout/session')->getInsuranceUpsellApply()) {
        parent::collect($address);

        $this->_setAmount(0);

        $items = $this->_getAddressItems($address);
        if (!count($items)) {
            return $this;
        }

        $quote = $address->getQuote();

            $exist_amount = $quote->getFeeAmount();
            $fee = $address->getGrandTotal() * (Mage::getStoreConfig('cart_insurance_upsells/configuration/discount_rate',Mage::app()->getStore())/100);
            $balance = $fee - $exist_amount;
            $address->setInsurance($balance);
            $quote->setInsurance($balance);
            $address->setGrandTotal($address->getGrandTotal() + $address->getInsurance());
        }
    }

    public function fetch(Mage_Sales_Model_Quote_Address $address)
    {
            $amt = $address->getInsurance();
            if ($amt > 0){
                $address->addTotal(array(
                    'code' => $this->getCode(),
                    'title' => 'Insurance Upsell',
                    'value' => $amt
                ));
                return $this;
            }
        return true;
    }
}

Config.xml :

  <config>
       <global>

        <pdf>
            <totals>
                <insurance>
                    <title>Upsell Insurance</title>
                    <model>cart_insurance_upsell/pdf_earning</model>
                    <font_size>7</font_size>
                    <display_zero>0</display_zero>
                    <sort_order>3</sort_order>
                </insurance>
            </totals>
        </pdf>

        <fieldsets>
            <sales_convert_quote_address>
                <insurance><to_order>*</to_order></insurance>
                <insurance><to_order>*</to_order></insurance>
                <insurance><to_invoice_item>*</to_invoice_item></insurance>
            </sales_convert_quote_address>
        </fieldsets>

        <sales>
            <quote>
                <totals>
                    <insurance>
                        <class>cart_insurance_upsell/paymentinsurance</class>
                    </insurance>
                </totals>
            </quote>
            <order_invoice>
                <totals>
                    <insurance>
                        <class>cart_insurance_upsell/earning</class>
                        <after>subtotal</after>
                    </insurance>
                </totals>
            </order_invoice>
        </sales>
 </global>
    </config>

And for the invoice:

class  Cart_InsuranceUpsell_Model_Earning extends Mage_Sales_Model_Order_Invoice_Total_Abstract
{
    public function collect(Mage_Sales_Model_Order_Invoice $invoice) {
        $order = $invoice->getOrder();
        $insurance = $order->getInsurance();

        $invoice->setInsurance($insurance);

        $invoice->setGrandTotal($invoice->getGrandTotal() + $insurance);

        return $this;
    }
}

And can u explain pls, how to work in config.xml that:

   <order_invoice>
                     <totals>
                         <insurance>


Get this bounty!!!

#StackBounty: #magento-1.9 Extra fee doesn't show at the admin panel orders

Bounty: 50

I added an extra fee. It’s working well at the checkout. enter image description here

But at the admin panel -> sales -> orders -> my order it doesn’t show.
enter image description here

But price is well.
At the invoice too

enter image description here

How can I show it?
I tried :

<fieldsets>
     <sales_convert_quote_address>
         <insurance><to_order>*</to_order></insurance>
         <insurance><to_order>*</to_order></insurance>
         <insurance><to_invoice_item>*</to_invoice_item></insurance>
     </sales_convert_quote_address>
</fieldsets>

But it doesn’t help. Thanks advance.

EDIT:

class Cart_InsuranceUpsell_Model_Paymentinsurance extends Mage_Sales_Model_Quote_Address_Total_Abstract
{
    protected $_code = 'Insurance Upsell';

    public function collect(Mage_Sales_Model_Quote_Address $address)
    {
        if (Mage::getSingleton('checkout/session')->getInsuranceUpsellApply()) {
        parent::collect($address);

        $this->_setAmount(0);

        $items = $this->_getAddressItems($address);
        if (!count($items)) {
            return $this;
        }

        $quote = $address->getQuote();

            $exist_amount = $quote->getFeeAmount();
            $fee = $address->getGrandTotal() * (Mage::getStoreConfig('cart_insurance_upsells/configuration/discount_rate',Mage::app()->getStore())/100);
            $balance = $fee - $exist_amount;
            $address->setInsurance($balance);
            $quote->setInsurance($balance);
            $address->setGrandTotal($address->getGrandTotal() + $address->getInsurance());
        }
    }

    public function fetch(Mage_Sales_Model_Quote_Address $address)
    {
            $amt = $address->getInsurance();
            if ($amt > 0){
                $address->addTotal(array(
                    'code' => $this->getCode(),
                    'title' => 'Insurance Upsell',
                    'value' => $amt
                ));
                return $this;
            }
        return true;
    }
}

Config.xml :

  <config>
       <global>

        <pdf>
            <totals>
                <insurance>
                    <title>Upsell Insurance</title>
                    <model>cart_insurance_upsell/pdf_earning</model>
                    <font_size>7</font_size>
                    <display_zero>0</display_zero>
                    <sort_order>3</sort_order>
                </insurance>
            </totals>
        </pdf>

        <fieldsets>
            <sales_convert_quote_address>
                <insurance><to_order>*</to_order></insurance>
                <insurance><to_order>*</to_order></insurance>
                <insurance><to_invoice_item>*</to_invoice_item></insurance>
            </sales_convert_quote_address>
        </fieldsets>

        <sales>
            <quote>
                <totals>
                    <insurance>
                        <class>cart_insurance_upsell/paymentinsurance</class>
                    </insurance>
                </totals>
            </quote>
            <order_invoice>
                <totals>
                    <insurance>
                        <class>cart_insurance_upsell/earning</class>
                        <after>subtotal</after>
                    </insurance>
                </totals>
            </order_invoice>
        </sales>
 </global>
    </config>

And for the invoice:

class  Cart_InsuranceUpsell_Model_Earning extends Mage_Sales_Model_Order_Invoice_Total_Abstract
{
    public function collect(Mage_Sales_Model_Order_Invoice $invoice) {
        $order = $invoice->getOrder();
        $insurance = $order->getInsurance();

        $invoice->setInsurance($insurance);

        $invoice->setGrandTotal($invoice->getGrandTotal() + $insurance);

        return $this;
    }
}

And can u explain pls, how to work in config.xml that:

   <order_invoice>
                     <totals>
                         <insurance>


Get this bounty!!!