#StackBounty: #magento-1.9 #category #404 #router Category "canShow" function returning true, but category controller shows f…

Bounty: 50

I created a new category, and when visiting it on frontend, it shows as a 404 page. It has all the same settings as other categories.

#File: app/code/core/Mage/Catalog/controllers/CategoryController.php

I added the following to debug the issue:

  protected function _initCatagory()
    {
       ...
        if (!Mage::helper('catalog/category')->canShow($category)) {
          var_dump(__METHOD__ . '::' . __LINE__);
          exit;
          return false;
        }
       ...
    }

Which triggers when hitting the category frontend

string(50) "Mage_Catalog_CategoryController::_initCatagory::54"

But when I debug further into the canShow function, it is my debug code directly above return true; that is triggered!

public function canShow($category)
    {
        if (is_int($category)) {
            $category = Mage::getModel('catalog/category')->load($category);
            var_dump(__METHOD__ . '::' . __LINE__);
            exit;
        }

        if (!$category->getId()) {
          var_dump(__METHOD__ . '::' . __LINE__);
          exit;
          return false;
        }

        if (!$category->getIsActive()) {
          var_dump(__METHOD__ . '::' . __LINE__);
          exit;
          return false;
        }
        if (!$category->isInRootCategoryList()) {
          var_dump(__METHOD__ . '::' . __LINE__);
          exit;
          return false;
        }

        var_dump(__METHOD__ . '::' . __LINE__ . 'RETURN TRUE');
        exit;
        return true;
    }

Returns:

string(53) "Mage_Catalog_Helper_Category::canShow::135RETURN TRUE"

So whats the deal? Why is it returning true, but failing the if statement inside of _initCategory() ?

If I remove the canShow check the category returns perfectly, I am tearing my hair out! Thanks in advance!


Get this bounty!!!

#StackBounty: #magento-1.9 #php #api #sales-order Magento 1.9 API Performance – Retrieving All Sales Order Info

Bounty: 50

I’m creating a page that shows order sales data such as sales revenue, total quantity of orders and also best sellers which consist of products from all sales orders.

The problem is that this takes 20 minutes to run for a database with only 1200 orders. I’m certain this is because an API call needs to be made for each order separately to retrieve the item information:

$orderDetails[] = array($client->salesOrderInfo($sessionId, $orderNumbers[$d]));

Here’s an example of my code:

    // API Connection.
    $client = new SoapClient('htps://www.mysite.com/api/v2_soap/?wsdl');
    $sessionId = $client->login('API Username', 'API Password');

    // Filter orders for this year only.
    $filter = array('complex_filter' => array(
           array('key' => 'created_at', 'value' => array('key' => 'gt', 'value' => $currentYear . '2017-01-01 00:00:00'))
       )
    );

    // Call the API and retrieve the orders.
    $orders = $client->salesOrderList($sessionId, $filter);

    // Loop through orders and store order numbers against the $orderNumbers array.
    $orderNumbers = array();
    for ($i = 0; $i < count($orders); $i++) {
        $orderNumbers[] = $orders[$i]->increment_id;
    }

   // Loop through order numbers and store the order details against the $orderDetails array (this seems to be the problem area).
   $orderDetails = array();
   for ($d = 0; $d < count($orderNumbers); $d++) {
      $orderDetails[] = array($client->salesOrderInfo($sessionId, $orderNumbers[$d]));
   }

Is there a way of improving my script so that it performs much better? I cannot find a way of retrieving sales order info for more than one order at a time.

Thanks so much for any help.


Get this bounty!!!

#StackBounty: #magento-1.9 #collection #layered-navigation Layered Navigation wrong filtering custom attributes

Bounty: 50

I have added a couple of custom attributes to my store.
The default ones, like category or price is listing and filtering correctly.

By filtering correctly I mean correct displaying all of another filters (along with quantities) and price slider for example.

The problems starts whenever I try to select a custom made attribute. For example “Płeć” which is a gender. After selecting, the filters are showing (1) everywhere in products, as well as price slider is stopping to work. What is wrong with filtering ?

Here is my website with direct link to one of categories.


Get this bounty!!!

#StackBounty: #magento-1.9 #orders #backend "Group" is a required value when creating a new order from backend

Bounty: 50

After I upgraded to Magento 1.9.3.4 this error message appears when creating a new order with a new client:

“Group” is a required value.

I tried selecting a different group (default is General) but it’s the same. It was working before the update.

screenshot with Group is a required value error message


Get this bounty!!!

#StackBounty: #magento-1.9 #fedex #address #ups How to Add Multiple Pickup Address

Bounty: 50

I have two stores, one from San San Antonio and another one Detroit. I will get the details from the customer,

enter image description here

I am using FedEx and UPS,

Supposed user select San Antonio, San Antonio based shipping charges display to the customer (This my current process) if customer select Detroit, Detroit based shipping charges display to the customer(Need to configure).

My one of the store running in San Antonio, so shipping charge display to the customer.

My another store will be open on next month in Detroit, so how can display shipping charge based on Detroit, because my pickup point Detroit(By Default my store display San Antonio based pickup charge to customer )

How can I add two pickup address charges method to the customer, if customer select San Antonio, display San Antonio based shipping charge (current process working fine), also how can I display Detroit pickup shipping charges to the customer?

enter image description here

How can I configure more than one pick up address?


Get this bounty!!!

#StackBounty: #magento-1.9 #checkout #shopping-cart-price-rules #coupon-codes Discount from Specific Shipping Method based on coupon co…

Bounty: 50

I need in admin section to apply coupon only on particular shipping method not discount from other shipping method. I should be able to select shipping method in admin which I want to allow for discount.

In frontend whenever customer apply that coupon, the amount should not deducted from the subtotal/ grand total, Only the particular shipping method(Which we had allowed in admin section) should be pre-selected and shown with discount applied.

Please find the sample screenshot in attachment. This is what I want to achieve.

Frontend Checkout page

Coupon Code

Admin Section


Get this bounty!!!

#StackBounty: #magento-1.9 #shipping #shipping-methods #quote #shipping-address Creating Quote Address the right way

Bounty: 50

I’m trying to create a quote address programmatically, everything is working fine and the order is created, however this is after 2 workarounds im not sure why i need them, I’ll list all the observations I have and hopefully someone can point out what im doing wrong.

My biggest problems is calculating the shipping cost, and the way a shipping address is created, so let’s say the basic way to create a quote order is as follows (don’t mind the variables) :

// Initializing the Quote Model, all good here
$quote = Mage::getModel('sales/quote')
    ->setStoreId($store_id)
    ->setWebsiteId($website_id)
    ->assignCustomer($customer);

// The shipping address, all good here
$shipping_address = array(
    'prefix' => '',
    'firstname' => $customer->getFirstname(),
    'middlename' => '',
    'lastname' => $customer->getLastname(),
    'suffix' => '',
    'company' => '',
    'street' => array(
        '0' => $d['street'],
        '1' => ''
    ),
    'city' => $d['city'],
    'country_id' => $d['country_id'],
    'region' => $d['region'],
    'postcode' => '0000',
    'telephone' => $customer->getPhone(),
    'fax' => '',
    'vat_id' => '',
    'save_in_address_book' => 1
);

// Adding a product, all good here
$quote->addProduct($product_model, new Varien_Object(
    array(  'qty' => 1,
            'options' => $options
        )
));

// Setting the shipping/billing address
$quote->getShippingAddress()->addData($shipping_address);
$quote->getBillingAddress()->addData($shipping_address);

// Setting the shipping method, all good here as well
$methods = Mage::getSingleton('shipping/config')->getActiveCarriers();
foreach($methods as $_code => $_method){
    // Get the first allowed method of this shipping carrier
    $m = key($_method->getAllowedMethods());
    $shipping_method = $_code . '_' . $m;
}
$shippingAddress->setShippingMethod($shipping_method);

// Collecting the shipping rates, i have no clue what im doing wrong here
$shippingAddress->setWeight(90); // I will have to set his manually, not sure why
$shippingAddress->setFreeMethodWeight(90); // I will have to set this manually, not sure why
$shippingAddress->setShippingMethod($shipping_method);
$shippingAddress->setCollectShippingRates(true);
$shippingAddress->collectShippingRates();

$quote->collectTotals();

Now I want to retrieve the shipping cost, so I just do a $quote->getShippingAddress()->getShippingAmount().

The problem is I have to set the shipping weight as follow for this to work, as in the code block above:

$shippingAddress->setWeight(90);
$shippingAddress->setFreeMethodWeight(90);

This is because for some reason, in

app/code/core/Mage/Sales/Model/Quote/Address.php:913

$request->setPackageWeight($item ? $item->getRowWeight() : $this->getWeight());

The getWeight function returns 0, if i didn’t set it explicilty, and it makes sense, since in my code i don’t find anywhere it’s calculated or modified when im adding the products to fetch the weight from. So this is my first issue, why im setting the weight explicitly, why i need to do so.

The second issue is the $shippingAddress->setFreeMethodWeight(90); line, i have to do this as well, because in

app/code/Mage/Shipping/Model/Carrier/Tablerate.php:138

// Package weight and qty free shipping
$oldWeight = $request->getPackageWeight();
$oldQty = $request->getPackageQty();

$request->setPackageWeight($request->getFreeMethodWeight());
$request->setPackageQty($oldQty - $freeQty);

$result = $this->_getModel('shipping/rate_result');
$rate = $this->getRate($request);

$request->setPackageWeight($oldWeight);
$request->setPackageQty($oldQty);

The getRate function is calculated after setting the package weight to the return value of getFreeMethodWeight, which is null if I didn’t set it as above. I have the FreeShipping shipping method disabled, and no Cart Price rules, so I have no idea why the above lines are written this way.

That’s pretty much it. Hopefull I was able to explain everything.


Get this bounty!!!

#StackBounty: #magento-1.9 #shipping #tax #quote #create-order Creating Order and Collecting Totals

Bounty: 50

I’m having a very hard time collecting the right totals when creating an order by code (magento 1.9, php5.4). I’m creating a quote as you noramlly would, added products and shipping/billing address, and now I’m collection the subtotal/shipping/taxes/grandtotal, and im not getting the right calculations.

For the example below, I have the following:

Product Price is 100
Taxes on Product Price is 25
Shipping Amount is 10
Shipping Taxes is 2.5
Grand total should be 137.5

When when executing $quote->collectTotals(); to get the order grand total, im always getting 110 for $quote->getGrandTotal() or $quote->getShippingAddress()->getGrandTotal(). I should be getting 137.5.

So I google around and did my homework, and apparently there was a problem in the order of the collection, so magento was collecting using the following order:

tax_shipping
nominal
subtotal
freeshipping
tax_subtotal
weee 
shipping 
discount 
grand_total
msrp 
tax 

and the following total amounts were calculated:

enter image description here

So it looked like grand_total was calculated before adding the tax, and this is why I was getting 110 instead of 137.5, which makes sense, since all what the grand total class does is to sum up the total:

class Mage_Sales_Model_Quote_Address_Total_Grand extends Mage_Sales_Model_Quote_Address_Total_Abstract
{
    /**
     * Collect grand total address amount
     *
     * @param   Mage_Sales_Model_Quote_Address $address
     * @return  Mage_Sales_Model_Quote_Address_Total_Grand
     */
    public function collect(Mage_Sales_Model_Quote_Address $address)
    {
        $grandTotal     = $address->getGrandTotal();
        $baseGrandTotal = $address->getBaseGrandTotal();

        $store      = $address->getQuote()->getStore();
        $totals     = array_sum($address->getAllTotalAmounts());
        $totals     = $store->roundPrice($totals);
        $baseTotals = array_sum($address->getAllBaseTotalAmounts());
        $baseTotals = $store->roundPrice($baseTotals);

        $address->setGrandTotal($grandTotal+$totals);
        $address->setBaseGrandTotal($baseGrandTotal+$baseTotals);
        return $this;
    }

So I though if I changed the order of the collection, by moving the grand_total collection after the tax collection, this would solve my problem, so used i overrode the order using this simple extension https://github.com/hartmut-co-uk/magento-php7-totals-fix, after all it looked like a lot of people are facing the same issue with PHP7 and PHP5.5, although im using PHP5.4, i thought i would give it a shot, considering how desperate i am.

Now things are a bit different, the collection total changed to:

nominal
freeshipping
tax_subtotal
msrp
subtotal
weee
shipping
tax_shipping
discount
tax
grand_total

So I though all my problem went away, but for some reason, now the tax are not calculated the right way, I’m getting 2.5 for the tax instead of 27.5

enter image description here

I know the post is super long and can be hard to follow, but hopefully I was able to explain the problem. So the first question is:

  1. Why grand_total collector is not called in the right order in the first place.
  2. I have no idea what to do next. Suggestions are strongly welcomed :D.


Get this bounty!!!

#StackBounty: #magento-1.9 #product #sku #taxes How Can I Apply TAX Rule Based On Individual SKU Wise – Taxable Goods

Bounty: 50

I need to apply the tax rate for my all products with the unique tax rate, Tax rate different from each other, I mean all products have the own tax rate. How can I solve it?


Get this bounty!!!

#StackBounty: #magento-1.9 #orders #custom-options #csv How Can I Create Custom Order Using CSV with multiple Products along with Custo…

Bounty: 50

Many times I did the manual order for the customer, some order consists 100’s of products, how can I create custom order by using CSV? Is possible import order by CSV? or is possible to import order by programmatically?


Get this bounty!!!