A Must On Every Website You Install – Info.Php

For all you do-it-yourselfers, here’s some good advice. On every website you create, make an info.php file. This will allow you to see your php memory for your server and will allow you to know which version of php you have. This tool is very useful when dealing with databases and/or eCommerce websites (when you’re in the development stage, you often need to increase php memory to upload and download large files).

How to:

  1. Download notepad++ or sublime text so you have something to write php with.
  2. Connect notepad++ with your server and open the root folder (normally the ‘public_html’ folder)
  3. Create the following short text using your notepad++ or sublime text
    <?php phpinfo(); ?>
  4. Save your file directly into your ‘public_html’ server folder as ‘info.php’
  5. Now when you type your domain + info.php you will get the following report (example: golocalexpert.com/info.php)

 

If only it was that easy to just import data into Magento

Project Fix:

The more I work with Magento the more I realize how much is involved to do some minor tasks like uploading data. A great example of this is just how much chopping is involved to upload anything over 800 items. First, one must upload the data in increments disposed by the vps, then, the cache can only be cleaned by revamping the .csv after uploading everything.

here’s what one can do to speed up the process:

> Bumped PHP memory_limit up to 512MB and some MySQL tuning; nevertheless, in the end its all up to the server hardware.

> After getting processes enough memory to actually do something, you need to run your exports from a SSH command line. It will take about three hours to export 10,000 records in a new profile set to export \”sku,store,type,name,price,weight,qty,status\”

> On imports, the next tuning you can do is your record chunking factor. Having boosted your memory_limit per above so PHP has enough headroom to do some real work, you need to make a vital setting in your \”Import All Products\” Import Profile. When most people see the \”Number of Records\” field, they make a bad assumption that this is the total number of products that you intend to import.

This is a chunking factor, ie the number of records to be updated per operation. Set it to 5-20 records with 10 being a good all around number. If set too high, it will eat up memory to the point that nothing ever happens.

 

More on this: http://www.magentocommerce.com/boards/viewthread/113901/P0/

 

Magento Version 1.9.0.1

Magento Fatal error: Mage_ImportExport_Model_Export_Entity_Product.php

Project Fix:

I recently had to resolve this issue for a customer, and since it was quite easy to fix, I figured I’d share with all you developer and do it yourselfers.

Error Message:

Fatal error: Unsupported operand types in …/public_html/includes/src/Mage_ImportExport_Model_Export_Entity_Product.php on line 875

How to Fix:

  1. Goto app/code/core/Mage/ImportExport/Model/Export/Entity/Product.php
  2. Find: $dataRow += $stockItemRows[$productId];
  3. Replace with: $dataRow = array_merge($dataRow,$stockItemRows[$productId]);

Magento Version 1.9.0.1

Same SKUs, different Title and Description

Project Fix:

Here’s the next challenge, to list the same SKU to different products and descriptions in an Automotive Magento store I am developing. Magento does not allow for this to happen as the SKU must be unique (of course that makes sense but not for my case).

Background: Car parts shop: It is possible that one and the same article fits for different locations on the car. So it would not make sense to add another article with a different SKU/title/sescription for one and the same.

Looking for a work around. Stay tuned to my solution! The goal is to have several products with the same SKU but other descriptions and titles.

 

Magento Version 1.9.0.1

Skip The Paypal Express Review Page in Magento

Project Fix:

When using the Paypal Express Checkout with Magento you’ll notice the flow is choppy and increases cart abandonment. This is the current process which we will be fixing:

  1. Checkout page
  2. Redirect to Paypal website
  3. Redirect to Paypal Express Review page on our website
  4. Order success page

The Paypal Express Review page (3.) is unnecessary. We have all the information we need from the customer, so this is just adding another opportunity for the customer to abandon the order. Let’s streamline this. Hopefully I can save you some cash.

 

Create a copy of the following file in your local code directory (if you need explanation of this, ask me):

app\code\core\Mage\Paypal\Controller\Express\Abstract.php

 

Search in function ‘returnAction()’ for the following line of code:

PGNvZGU+JHRoaXMtPl9yZWRpcmVjdCgnKi8qL3JldmlldycpOzwvY29kZT4=

 

Change it to:

PGNvZGU+JHRoaXMtPl9yZWRpcmVjdCgnKi8qL3BsYWNlT3JkZXInKTs8L2NvZGU+

This essentially just says, “when we return from Paypal website, redirect to the ‘placeOrder()’ function instead.”

 

Next, create a copy of the following file in your local code directory:

app\code\core\Mage\Paypal\Model\Config.php

 

Find function ‘getExpressCheckoutStartUrl()’, and add a URL parameter to the list. So, from:

PGNvZGU+DQpwdWJsaWMgZnVuY3Rpb24gZ2V0RXhwcmVzc0NoZWNrb3V0U3RhcnRVcmwoJHRva2VuKQ0Kew0KICAgIHJldHVybiAkdGhpcy0+Z2V0UGF5cGFsVXJsKGFycmF5KA0KICAgICAgICAnY21kJyAgID0+ICdfZXhwcmVzcy1jaGVja291dCcsDQogICAgICAgICd0b2tlbicgPT4gJHRva2VuLA0KICAgICkpOw0KfQ0KPC9jb2RlPg==

 

To:

PGNvZGU+DQpwdWJsaWMgZnVuY3Rpb24gZ2V0RXhwcmVzc0NoZWNrb3V0U3RhcnRVcmwoJHRva2VuKQ0Kew0KICAgIHJldHVybiAkdGhpcy0+Z2V0UGF5cGFsVXJsKGFycmF5KA0KICAgICAgICAnY21kJyAgID0+ICdfZXhwcmVzcy1jaGVja291dCcsDQogICAgICAgICd1c2VyYWN0aW9uJyA9PiAnY29tbWl0JywNCiAgICAgICAgJ3Rva2VuJyA9PiAkdG9rZW4sDQogICAgKSk7DQp9DQo8L2NvZGU+

This adds a parameter to the Paypal URL that the customer visits. It tells Paypal to consider this a final step in payment, instead of verification only. This will just change the Paypal complete button from “Complete” (I think), to “Pay”

Done!

Magento Version 1.7.0.2