December 14, 2018

cm-mini

Thinking Magento

Manage Categories > Limited to 1000 Products Per Category

Did you recently move server or try to add more products in Magento through Catalog > Manage Categories and it reduced the number of products in the category to 1000 and no matter what you do it will not add another product.

This issue is down to your php.ini setting max_input_vars which is set to 1000 by default.

The recommended solution for this error would be to open you httpd.conf file or to create a virtualhost_global.conf

<LocationMatch "magentoshop/(index\.php/)?admin/">
<IfModule mod_php5.c>
php_value max_input_vars 8000
</IfModule>

The location match for the admin will help prevent the increased max_input_var from being exploited by Denial of Service (DDOS) attacks.

Not proficient with servers and just want to get out of this bind in a hurry, you can deploy a module fix on your server. Maksold is the original developer behind the event based module, I've just compiled it into a module for easy download and installation.

Download Module

Install on the server via ftp/sftp and flush your magento cache.

If this saved you hours of work or saved you from a headache, feel free to buy us a beer.

Configurable Product Is Creating A Simple Associated Product, But Ajax Loader Remains Spinning

As the title suggests for this one, this is an error you might have been receiving when you try and add associated products to a configurable product, however all that happens on the configurable screen is the spinning ajax wheel telling you it's loading.

The simple product is created correctly, however the screen for the configurable product does not update, your only option being to refresh the page.

I found this error was down to an update I made to combat against the Core_Url_Rewrite bug.

One solution had been to change the following code in 

app/code/core/Mage/Catalog/Model/Url.php 

Change:

if ($product->getUrlKey() == '' && !empty($requestPath) && strpos($existingRequestPath, $requestPath) === 0 ) 

To:

if (!empty($requestPath) && strpos($existingRequestPath, $requestPath) === 0 ) 

This change caused the issue with configurable products no longer being able to have the ajax loader update the associated products grid, requiring a refresh of the page to generate a new associated product and on top of that to save the association to the configurable.

So if you exhibit the symptons on your configurable ajax loader spinning indefinately and you made the above change. Then it's time to undo the change.

Note: In trying to debug this error, no error was being produced.

If this saved you hours of work or saved you from a headache, feel free to buy us a beer.

Create A Magento On Sale Category - The RIGHT Way

In a previous blog entry a few years back I wrote out a way to get sale products to show only. It's cumbsersome and not very elegant and work at a time when Magento was still fairly new.

In this entry I'm going to show you a revised way of doing this, which could be applied to filtering collections of any type such as price ranges, new products, custom attributes, date added etc, it's a fairly extensive list, which can be mapped in the .php file that you can find lower in the article.

So lets start with your category. Navigate in your admin to the category that you wish to show sale products only.

Catalog > Manage Categories or in EE Catalog > Categories > Manage Categories

Click on the category and go to the custom design tab and paste into the custom design layout box the following

<reference name="content">
<remove name="product_list"/>
<block type="catalog/product_sale" name="product_sale" alias="sale" template="catalog/product/list.phtml">
<block type="catalog/product_list_toolbar" name="product_list_toolbar" template="catalog/product/list/toolbar.phtml">
<block type="page/html_pager" name="product_list_toolbar_pager"/>
</block>
<action method="setLimit"><limit>32</limit></action>
<action method="setColumnCount"><columns>3</columns></action>
<action method="setToolbarBlockName"><name>product_list_toolbar</name></action>
<action method="addPriceBlockType">
<type>bundle</type>
<block>bundle/catalog_product_price</block>
<template>bundle/catalog/product/price.phtml</template>
</action>
</block>
</reference>
<reference name="product_list_toolbar">
<action method="setDefaultGridPerPage">
<limit>32</limit>
</action>
</reference>

One you've added that and saved, going to the category is going to produce an error because it's looking for the file Mage_Catalog_Block_Product_Sale.

Click here for file

Log in via ftp or sftp and place the file into app/code/local/Mage/Catalog/Block/Product/Sale

Going to the category will now show you only on sale products that are in stock.

Open up the Sale.php file if you wish to addAttributeToFilter. 

This tutorial is designed for those who just want to get the job done and out of the way and everyone needs a sale category the easy way.

If this saved you hours of work or saved you from a headache, feel free to buy us a beer.

DPD API Login Using Zend Framework

Now I'm posting this because I don't want someone else to go through the same hardship as I did when it came getting the geosession from the DPD api. It may look easy enough, but if you've not had a whole lot of experience with using Zend_Http_Client (POST) it may be a bit of a nightmare taking that initial first step. Once you have the geosession, you can start using more POST and GET calls to get the information that you require.

$base="https://api.dpd.co.uk";
$method = '/user/?action=login';
$url = $base.$method;
$client = new Zend_Http_Client($url);
$client->setMethod(Zend_Http_Client::POST);
$client->setHeaders('Host', 'api.dpd.co.uk');
$client->setHeaders(Zend_Http_Client::CONTENT_TYPE, 'application/json');
$client->setHeaders('Accept', 'application/json');
$client->setHeaders('Authorization', 'Basic '. base64_encode('username:password'));
$client->setHeaders('GEOClient', 'account name/account number');
$client->setHeaders('Content-Length', '0');
$response = $client->request();
$body = Zend_Json::decode($response->getBody());
$geoSession = $body['data']['geoSession'];

 

Error in the Ess M2ePro Extension!

Are you receiving the following error in your M2ePro Multichannel extension?

Call to a member function getData() on a non-object in app/code/community/Ess/M2ePro/Model/Mysql4/Ebay/Order.php on line 32

Now this error is actually fixed in the most recent version of ebay, but if you don't want to go through the process of upgrading, you can update this file.

Open up the file and you'll find

$itemIdSql = $readConnection->quoteInto('?', $orderItem->getData('item_id'));

Update it with the following

$itemIdSql = $readConnection->quoteInto('?', $orderItem['item_id']);
$transactionIdSql = $readConnection->quoteInto('?', $orderItem['transaction_id']);
$whereSql[] = "(item_id = {$itemIdSql} AND transaction_id = {$transactionIdSql})";