Technology & Development

  • How to change a product dropdown attribute to a multiselect in Magento

    First, update the attribute input type to multiselect:

    UPDATE eav_attribute SET
    entity_type_id = '4',
    attribute_model = NULL,
    backend_model = 'eav/entity_attribute_backend_array',
    backend_type = 'varchar',
    backend_table = NULL,
    frontend_model = NULL,
    frontend_input = 'multiselect',
    frontend_class = NULL
    WHERE attribute_id = 'YOUR_ATTRIBUTE_ID_HERE';
    Next, copy the attribute values from the old table to the new:
    INSERT INTO catalog_product_entity_varchar ( entity_type_id, attribute_id, store_id, entity_id, value)
    SELECT entity_type_id, attribute_id, store_id, entity_id, value
    FROM catalog_product_entity_int
    WHERE attribute_id = YOUR_ATTRIBUTE_ID_HERE;
    Finally,  remove the old values or they will conflict with the new setup (the old values will load, but Magento will save new values to the varchar table):
    DELETE FROM catalog_product_entity_int
    WHERE entity_type_id = 4 and attribute_id = YOUR_ATTRIBUTE_ID_HERE;
    Credit to Meabed's post for the initial concept: Update regarding entity_type_id value referenced in the above example: The value for "entity_type_id" that you'll want to use may not always be "4" as referenced above. You'll want to check the table "eav_entity_type" and find the entry that has the "entity_type_code" set to "catalog_product". The "entity_type_id" for that record is the value you need to use. In most cases this value is either "4" or "10", but this may vary in future versions of Magento. Thanks to David Line for the heads up and providing these instructions.

  • Using Facebook Open Graph META Tags

    When someone likes a page on your website or shares your site in a post, Facebook automatically includes a thumbnail image, title and description for the page. This is great, until Facebook finds that one unsightly image from the bowels of your site and decides to use that as your organization's social media banner.

    That being said, how do you control which image Facebook uses when your site is shared? How about the title and description? Read on.

    Facebook and Open Graph

    Open Graph is an API that allows developers to work with Facebook's platform in a structured manner. That is, it gives you a way to communicate with Facebook through the use of metadata, API calls, and other developer tools.

    When someone shares your page, Facebook looks for Open Graph metadata in your site's HTML that will help it describe your content – the thumbnail image being one of those pieces of information. Below are some basic instructions for defining the metadata necessary to specify the thumbnail image, title and description Facebook should use for your page.

    Specifying your Page's Thumbnail Image, Title and Description

    Step 1)

    Use the Open Graph debugger to see Facebook's recommendations for your specific page. This is a great tool for gaining insight into how Facebook sees your content. To use the tool, simply type in your page's full URL and hit the debug button.

    On the next page, you'll likely see some warnings like these:


    Step 2)

    Now, open up your favorite HTML code editor and insert the following code between the <head> and </head> tags on your page. Replace the content sections with your own content, of course.

    <meta property="og:title" content="Awesome, Inc. – We're even more awesome.">
    <meta property="og:description" content="Awesome's mission is to take cool to a whole new level.">
    <meta property="og:image" content="">
    <meta property="og:image:secure_url" content="">
    <meta property="og:image:type" content="image/png">
    <meta property="og:image:width" content="1500">
    <meta property="og:image:height" content="1500">
    You'll notice that the image width and height are 1500x1500 pixels, which is what Facebook recommends. The minimum image dimensions you can use are 200x200 pixels. If you go any smaller, Facebook will ignore your recommendation and use a different image from your page.

    Also, specifying the og:image:secure_url meta property is optional. If you don't have an SSL certificate installed on your site, simply skip this step.

    Step 3)

    Run the Open Graph debugger on your page one more time. This will force Facebook to scrape your page's content and update their database with your updated metadata!

    That's it for now. You can find more information on Open Graph and images here.

  • Renaming Database Tables Using Laravel 4's Schema Builder

    If you're like us and have been playing around with the Laravel 4 beta, you've probably been enjoying the database migrations and other utilities that come with it out of the box. For us, as we've been building Quillio - our upcoming service built on Laravel 4 - the database migrations and schema builder have been instrumental in keeping our local and beta development environments in sync, and then again when we're ready to go to production. And if you're like us and constantly refine and improve your application, you've probably had to rename a database table or two during development. Unfortunately, on the surface it doesn't look like Laravel 4's schema builder has an easy way to do this - but looks can often be deceiving. I've been diving into Laravel 4's core files more and more lately to get a better understanding of what it can do, especially since the documentation is still in flux and being fleshed out. It was while I was poking around these files one day that I discovered the schema builder does, in fact, have a method to rename database tables for you, making it nice and easy to call this from within your database migrations and helping you avoid writing raw SQL, which isn't very portable from driver to driver and I personally always have to look up the syntax. So how exactly do you rename a table using Laravel 4's schema builder?

    Schema::rename($from, $to);
    That's it! It really couldn't be simpler. Just call Schema::rename() and pass in the original table name and the new one you'd like to rename it to. Here's an example of how this might look in a migration where we want to rename table 'foo' to 'bar':
    use IlluminateDatabaseMigrationsMigration;
    class RenameFooTable extends Migration {
    	 * Run the migrations.
    	 * @return void
    	public function up()
    		Schema::rename('foo', 'bar');
    	 * Reverse the migrations.
    	 * @return void
    	public function down()
    		Schema::rename('bar', 'foo');
    Sometimes you just have to get your hands dirty and dive into the source code a bit and you'll uncover some simple, but incredibly useful, gems like this one. I hope this quick tip helps keep your development quick and migrations clean! We'll post more hidden features like this as we uncover them, so stay tuned!

  • Magento - Making the telephone field not required at checkout

    Out of the box, the Magento checkout process requires users to enter a telephone number for both billing and shipping addresses. If your business doesn't have this requirement, you may want to remove this validation from one or both address forms. The steps below will remove the telephone requirement on the shipping address form during checkout. This has been tested with Magento Community Edition

    Step 1

    The first step is to modify the one page checkout templates for the address form(s) in which you want to remove the telephone requirement. The shipping address form is located here: /app/design/frontend/base/default/template/checkout/onepage/shipping.phtml DO NOT modify the base template file directly. Instead, copy this file into your site's own theme and make your modifications there. Base template files can be overwritten during Magento upgrades, so if you modify these files directly, you'll probably loose all of your work! Open your copy of shipping.phtml and look for the line:

    <label for="shipping:telephone" class="required"><?php echo $this->__('Telephone') ?></label>
    Replace it with (remove required class):
    <label for="shipping:telephone"><?php echo $this->__('Telephone') ?></label>
    Next, look for the line:
    <input type="text" name="shipping[telephone]" value="<?php echo $this->escapeHtml($this->getAddress()->getTelephone()) ?>" title="<?php echo $this->__('Telephone') ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('telephone') ?>" id="shipping:telephone" onchange="shipping.setSameAsBilling(false);" />
    And replace it with (comment out echo):
    <input type="text" name="shipping[telephone]" value="<?php echo $this->escapeHtml($this->getAddress()->getTelephone()) ?>" title="<?php echo $this->__('Telephone') ?>" class="input-text <?php //echo $this->helper('customer/address')->getAttributeValidationClass('telephone') ?>" id="shipping:telephone" onchange="shipping.setSameAsBilling(false);" />
    That's it. Save your new template file.

    Step 2

    Next, we need to modify the Magento Customer Address class to comment out some validation code. The code is located in an abstract class, so we can't override it. Instead, we'll make a copy of the file in the /app/code/local, which Magento will find and use instead of the core file. Copy the file: /app/code/core/Mage/Customer/Model/Address/Abstract.php To: /app/code/local/Mage/Customer/Model/Address/Abstract.php NOTE: You'll likely have to create the proper folder under /app/code/local. Now, open /app/code/local/Mage/Customer/Model/Address/Abstract.php and on line 375 find the following code:

    if (!Zend_Validate::is($this->getTelephone(), 'NotEmpty')) {
            $errors[] = Mage::helper('customer')->__('Please enter the telephone number.');
    Replace the above code with (comment out the entire block):
            // Disable telephone field validation
            if (!Zend_Validate::is($this->getTelephone(), 'NotEmpty')) {
                $errors[] = Mage::helper('customer')->__('Please enter the telephone number.');
    Save your modified Abstract.php file and proceed to the next step.

    Step 3

    Some of Magento's field validation logic is determined by the configuration of EAV attribute values, so we'll need to update a few rows in the Magento database. You'll need to make two small edits:

    1. Open the table eav_attribute and search for the row with attribute_code = "telephone". Make note of the attribute_id of this row. Next, set the column is_required to 0 (zero).
    2. Now, open the table customer_eav_attribute and search for the row with the same attribute_id as you noted in the previous step. Set the column validation_rules on this row to NULL.

    Step 4

    Finally, you'll need to clear all of Magento's caches so that your changes take effect. In the Magento admin, got to System -> Cache Management, and clear all caches. Make sure to click the 'Flush Magento Cache' and 'Flush Cache Storage' buttons as well. This will force Magento to take note of your database changes.

    Wrap Up

    That's it! When entering a new shipping address at checkout, Magento should no longer require a value for telephone. If you have any suggestions for improving these steps, please leave a comment below.

  • Using mod_rewrite to force HTTPS-only transfers

    Some websites require that all content be served securely using HTTPS. This is easily accomplished using Apache mod_rewrite directives. Just add the configuration below to a file named ".htaccess" in the root directory of your web site:

    <IfModule mod_rewrite.c>
    RewriteEngine On
    # Add a trailing slash to directories and force SSL
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteCond %{REQUEST_URI} !(/$)
    RewriteCond %{SERVER_PORT} 80
    RewriteRule (.*) https://%{HTTP_HOST}/$1/ [R=301,L]
    # Force SSL for file requests
    RewriteCond %{SERVER_PORT} 80
    RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R,L]

  • Multi-Store Magento Platforms from Swarming Technology (in Milwaukee, WI)

    NEED TO MANAGE MULTIPLE ONLINE STORES? Magento is an extremely powerful e-commerce platform for businesses operating stores for multiple clients, customer groups, or departments. Ask us about our multi-store Magento solutions for: • Promotional Products Companies • Multi-Channel Distributors • Dealer or Distibutor Networks Call Swarming Technology today and we’ll guide you through the entire process. (888) 855-8632

  • Magento Enterprise Development in Milwaukee Wisconsin!

    Magento Enterprise Development | Swarming Technology - Milwaukee Wi MAGENTO ENTERPRISE DEVELOPMENT Looking to launch a store running on Magento Enterprise Edition? Look no further. Unlike most Magento Enterprise developers, we have years of experience developing and running stores using Magento Enterprise Edition. From start to finish, we'll be there to do the installations and following through till you and your staff are trained. Call Swarming Technology today and we’ll guide you through the entire process. (888) 855-8632

  • Magento e-Commerce Tailored for B2B in Milwaukee, WI

    MAGENTO, TAILORED FOR B2B E-COMMERCE Out of the box, Magento has every feature necessary to run a successful e-commerce store. We've taken that foundation, and built upon it to create a truly unique B2B e-commerce powerhouse. Whether you have an existing Magento e-commerce site, or just starting. Swarming Technology has the experience and knowledge to give your store an extra edge over your competition. Contact Swarming Technology today for a custom Magento e-commerce quote! (888) 855-8632

8 Item(s)