Configuring a Magento development environment with Ubuntu and Vagrant

magento_vagrant

Starting a new Magento project (or any framework backed project) can involve tedious tasks before you even begin coding. Download the latest Magento version, extract, configure a database, update the application config etc… It can take quite a while to get going.

What if you could run a few simple commands to automate the above steps?

What if you could automatically configure a development environment using a virtual machine to closely emulate a production environment?

With Vagrant, both of the above are possible (and a whole lot more).

Continue reading

Hiding and showing the iOS status bar in Phonegap 2.5.0

After setting up a new Phonegap 2.5.0 project in Xcode, I noticed the IDE was warning of a deprecation in the Phonegap sample app:

‘useSplashScreen’ is deprecated. Deprecated in Cordova 2.5. Add/Remove the SplashScreen plugin instead of setting this property.

Phonegap 2.5.0 includes a change to the way the application splash screen is shown and hidden, and this property is no longer used. Instead, the CDVSplashScreen plugin handles this duty and exposes a couple of additional properties, such as auto hide, show spinner etc. These are declared in the project config.xml file.

Continue reading

Querying Magento’s Customer EAV and Newsletter Subscriber Data

Magento’s EAV data structure makes storing and extending customer information infinitely flexible. This is great if you’re writing reports for Magento’s admin panel, much of the complexity is abstracted by the fantastic MVC system, and the heavy lifting is performed by the ORM.

Sometimes however, you just need to run a quick SQL query on the database. For example, retrieve all UK customers who have subscribed to the newsletter. This is where Magento can become a little tricky to work with.

The following query retrieves customers who are subscribed to a Magento store newsletter and have GB as their default shipping address country. It also formats the firstname and lastname fields as these’s aren’t cleaned up when they’re saved. Of course it can be optimised, but it’s fine for the odd ad-hoc report.

SELECT c.entity_id, c.email, CONCAT(UCASE(LEFT(cev.value, 1)), 
LCASE(SUBSTRING(cev.value, 2))) AS firstname, 
CONCAT(UCASE(LEFT(cev2.value, 1)), 
LCASE(SUBSTRING(cev2.value, 2))) AS lastname,
caev.value as shipping_country
FROM customer_entity AS c 
JOIN customer_entity_varchar AS cev ON(cev.entity_id = c.entity_id) 
JOIN customer_entity_varchar AS cev2 ON(cev2.entity_id = c.entity_id)
JOIN sales_flat_order AS o ON(o.customer_id = c.entity_id) 
JOIN customer_entity_int AS cev3 ON (cev3.entity_id = c.entity_id)
JOIN customer_address_entity_varchar AS caev ON (cev3.value = caev.entity_id)
JOIN newsletter_subscriber AS ns ON(ns.customer_id = c.entity_id)
WHERE cev.attribute_id IN 
(
	SELECT ea.attribute_id 
	FROM eav_attribute AS ea 
	WHERE ea.attribute_code = "firstname" 
	AND entity_type_id = 1
) 
AND cev2.attribute_id IN 
(
	SELECT ea.attribute_id 
	FROM eav_attribute AS ea 
	WHERE ea.attribute_code = "lastname" 
	AND entity_type_id = 1
)
AND cev3.attribute_id IN
(
	SELECT ea.attribute_id 
	FROM eav_attribute AS ea 
	WHERE ea.attribute_code = "default_shipping" 
	AND entity_type_id = 1
)
AND caev.attribute_id IN
(
	SELECT ea.attribute_id 
	FROM eav_attribute AS ea 
	WHERE ea.attribute_code = "country_id" 
	AND entity_type_id = 2
)
AND ns.subscriber_status = 1
AND caev.value = 'GB'
GROUP BY c.entity_id

Installing Android 4.2 SDK and Phonegap 2.4.0 on Windows 7 step-by-step

pg_android
The following post is my account of the installation and configuration of Java 1.7 JDK, Android SDK 4.2, Ant and Phonegap 2.4.0 on Windows 7.

Most of the steps involved are covered by the Phonegap Getting Started Guide for Android guide, however I ran into a few issues requiring me to spend a while problem solving. I have elaborated on the parts the guide doesn’t mention, hopefully this post will save someone a few hours.

Continue reading