Magento: Get minimal and maximal price of bundle product

Tweet about this on TwitterShare on LinkedInShare on Google+Share on FacebookEmail this to someone

During last 2 weeks I worked a lot with bundle products. My task was to get the maximal and minimal prices of bundle product. I used those prices in order to create meta data for schema.org – AggregateOffer. I had to find a way how to get the maximal and minimal price of bundle product. Below you will find a snippet that provides a solution. The snippet was taken from “app/design/frontend/base/default/template/bundle/catalog/product/price.phtml” in Magento CE 1.9 .

/**
 * @var $_priceModel Mage_Bundle_Model_Product_Price
 */
$_priceModel  = $_product->getPriceModel();

list($_minimalPriceTax, $_maximalPriceTax) = $_priceModel->getTotalPrices($_product, null, null, false);
list($_minimalPriceInclTax, $_maximalPriceInclTax) = $_priceModel->getTotalPrices($_product, null, true, false);

// Debug info
var_dump($_minimalPriceTax); //float(104.4)
var_dump($_maximalPriceTax); //float(104.4)
var_dump($_minimalPriceInclTax); //float(104.4)
var_dump($_maximalPriceInclTax); //float(104.4)

Your thoughts?

Tweet about this on TwitterShare on LinkedInShare on Google+Share on FacebookEmail this to someone

Magento: Generate modman files

Tweet about this on TwitterShare on LinkedInShare on Google+Share on FacebookEmail this to someone

Last few weeks me and my team had to install around 10 third party Magento extensions. We have our own local setup and development workflow, but one of the key elements is MODMAN. All extensions (ours and the third party extensions) are linked in Magento by modman. With our current setup and the situation with the number of the new third party extensions we were forced to create modman files for all new extensions. We had to create manually the definitions in the modman files in order to define how the extensions files should be linked in Magento. There was no room for mistakes, but during the process we started experiencing problems, because of the human factor. From time to time we were missing to write modman definitions for some template, layout and css files.

I spotted the need that we need reliable and automated tool, which allows us to create modman files without missing any definitions. At the beginning I was thinking to write my own shell scrip, but as I didn’t want to reinvent the wheel I decided to use my professional network and to ask the Magento community (thanks to one of my first mentors Stefan Stefanov for always reminding me to search for existing concepts / tools / frameworks rather than reinventing the wheel). I asked for help in twitter. The first minute I published my tweet I got answers from Magento community members.

Modman generator question - tweet
Continue reading “Magento: Generate modman files”

Tweet about this on TwitterShare on LinkedInShare on Google+Share on FacebookEmail this to someone

Magento: Remove the region from address form

Tweet about this on TwitterShare on LinkedInShare on Google+Share on FacebookEmail this to someone

Today I worked on task that required the region filed to be removed from all Magento address forms. I found some Magento modules that were doing the trick, but I also wanted to delve a bit more deeper and to see if I can do this by configuration from Magento admin. Luckily in the most recent version of the platform ( Magento CE 1.9 ) this is possible.

By some simple actions in the Magento admin you will be able to exclude the region field from:

  • Customer add / edit address form
  • Customer register form
  • Billing and Shipping address form on the checkout page

Below I am going to show 2 different solutions how to hide the region filed. The first is more suitable for Magento admins / store owners and the second is something that the developers can use in their data upgrade scripts.

For the both example below I assume that we have to remove the region if the country is Germany.
Continue reading “Magento: Remove the region from address form”

Tweet about this on TwitterShare on LinkedInShare on Google+Share on FacebookEmail this to someone

From the archives: Osijek Software City hackathon – April 2012

Tweet about this on TwitterShare on LinkedInShare on Google+Share on FacebookEmail this to someone

Today, while I was browsing YouTube, I accidentally stumbled upon a video from April 2012. The video was from a hackathon organised by Osijek Software City and the main character was me. I had completely forgotten about the great time that I had back in 2012 and watching this video again made my day.

Also, I mustn’t forget to say “thanks” to my friends from Inchoo who invited me to attend this event. I remember that the trip from Bulgaria to Osijek was long and I felt very tired, but it was definitely worthy. I met new people at the hackathon and I had some great personal and technical conversations. As a matter of fact, I met my friend Vedran Subotic at this event who, two years after “opened the door” for my moving to München, Germany.

On the hackathon I had to work alone because most of the attendees had teams and the attendees who were alone were too far from my professional expertise. I wanted to do something with Magento but the potential team members were good at C#.
Continue reading “From the archives: Osijek Software City hackathon – April 2012”

Tweet about this on TwitterShare on LinkedInShare on Google+Share on FacebookEmail this to someone

An idea how to discover the nightlife of München

Tweet about this on TwitterShare on LinkedInShare on Google+Share on FacebookEmail this to someone

Almost every Wednesday I visit an event organized by the Facebook group – Munich – International friends. The event is called “The round table” and the main goal is to meet and socialize with new people. Most of the people on this event are foreigners and the common language is English, so it’s really good for non German speakers.

Before 3 weeks I went to the event after work and I wasn’t in mood to communicate and to socialize, because I had busy work day. For my good I met one of the most active group members, who was offering decks with special cards. The cards actually were free passes or free drink vouchers for different night clubs in München. You can check this website for more information – http://www.muenchenontherocks.de Initially I didn’t welcome the idea and even didn’t want to look at the cards, but later I change my mind. I got the idea to get one deck and later (when I am bored), from time to time to pull a card and to visit a club, which I would visit for first time.
Continue reading “An idea how to discover the nightlife of München”

Tweet about this on TwitterShare on LinkedInShare on Google+Share on FacebookEmail this to someone

Pay rate raise as result of being honest with my clients

Tweet about this on TwitterShare on LinkedInShare on Google+Share on FacebookEmail this to someone

During my period of running own business I had my good and bad moments. Clients were coming and going, there were months of good income and months of bad income. Somehow I was balancing for 2 years and I was constantly looking for the client who can support me with stable income in long term.

For about 8 months I had this client and it was real pleasure to work with him. The beginning was a bit hard. First I worked directly with him, but as he was a CEO of middle-size company and he was really busy he had to delegate the communication with me to another person called Mr. X. We had huge communication issues with Mr. X and I had to escalate this. Then the CEO delegated the communication to another person from his company and we were able to really start do work, because we were good match with my new point of contact.

Both companies had to do some small compromises in benefit of the business relationship and of course to get the job done. I also have to say that the client was really satisfied, because we were able to solve some problems that were blockers for his business. In other words, he was impressed of our skills and capabilities. I like to put excerpt of my email communication with this client. Basically after being honest and transparent with him I managed to get an increase for my company. I will name the client – Mr. Director.
Continue reading “Pay rate raise as result of being honest with my clients”

Tweet about this on TwitterShare on LinkedInShare on Google+Share on FacebookEmail this to someone

Open letter to 2 Magento frontend developers

Tweet about this on TwitterShare on LinkedInShare on Google+Share on FacebookEmail this to someone

Good morning P. and P.

As we we couldn’t catchup yesterday and I couldn’t feed you with proper feedback, then I promised to write you an open letter with all the points that I wanted to discuss.

First of all thanks for the git pull request and giving me the chance to review your code. I have to say that in general I am quite impressed. You managed to “draw the line” where is the scope your work and you properly marked the places inside the templates where the backend team have to step in. The idea with the TODOs and the timestamp was really original. This will make the things for us much more easier in the near future, when we will replace your static texts with our data getters.

There was something specific for your pull request. It contained many commits and it was representing your work from the last weeks. I noticed some small issues that were repeated in different template files.
Continue reading “Open letter to 2 Magento frontend developers”

Tweet about this on TwitterShare on LinkedInShare on Google+Share on FacebookEmail this to someone

Magento: SQL query that lists all orders having more than one invoice

Tweet about this on TwitterShare on LinkedInShare on Google+Share on FacebookEmail this to someone

Recently, a friend developer who is new to Magento asked me: “How can I find all orders that have more than one invoice?”. His company’s accounting department have found that they have more than 1 invoice for some orders, but according to the company’s business rules, they must have exactly 1 invoice per order.

I offered my help and managed to write a very simple query that could help him.

Sql query that list all orders that have more than 1 invoice:

SELECT sales_flat_order.*, COUNT(sales_flat_invoice.order_id)
	FROM sales_flat_order, sales_flat_invoice
	WHERE sales_flat_order.entity_id = sales_flat_invoice.order_id
	GROUP BY sales_flat_invoice.order_id HAVING COUNT(*) > 1;

Hope that this helps somebody else!

Your thoughts / questions?

Tweet about this on TwitterShare on LinkedInShare on Google+Share on FacebookEmail this to someone

Magento: Tips and tricks how to test Unirgy Dropship module with EcomDev PHPUnit

Tweet about this on TwitterShare on LinkedInShare on Google+Share on FacebookEmail this to someone

A couple of months ago I had a really interesting and very importatnt task. I had to code an automated process that creates Unirgy_DropshipPo purchase orders (Unirgy_DropshipPo_Model_Po objects). Because the task had a very high business value and everything had to work flawlessly, I decided to invest more energy and time in order to write a good test coverage with phpunit. I also knew that I needed tests because there was a big chance my code would be modified in the following weeks because of the business dynamics. I decided to “step” on something that I already knew how to utilise – EcomDev_PHPUnit ( Thank you Ivan Chepurnyi ).

Initially, my idea was to use EcomDev_PHPUnit only as a unit-testing tool and to test functions in isolation, but at a later stage of the development I found out that it would be even better if I used EcomDev_PHPUnit to test different branches of my algorithm.

During the development phase I had 3 main technical challenges:

  1. Unknown / Unexpected behaviour of Unirgy Dropship
  2. Collecting fixtures data in order to simulate test cases close to production environment
  3. Querying the database in order to prove that entities have been modified or created (Purchase order, credit memos and etc.)

Continue reading “Magento: Tips and tricks how to test Unirgy Dropship module with EcomDev PHPUnit”

Tweet about this on TwitterShare on LinkedInShare on Google+Share on FacebookEmail this to someone