Categories
Blog Magento

Magento 2 installing new php library via composer

Hi,
I had to install php library phpoffice/phpexcel for reading and writing excel files with php. The easiest solution seemed to be to use composer. But running the command
composer require phpoffice/phpexcel
gave me an error:

composer require phpoffice/phpexcel

[Composer\Downloader\TransportException]
Invalid credentials for 'https://repo.magento.com/packages.json', aborting.

require [--dev] [--prefer-source] [--prefer-dist] [--no-plugins] [--no-progress] [--no-update] [--update-no-dev] [--update-with-dependencies] [-ignore-platform-reqs] [--sort-packages] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--] []...

There were a couple of things I had to do to make my composer install the needed library.

Add your public and private keys

In order to use the composer with magento 2 you first need to add the authentication details to your magento. That’s easy-peasy.

  • Go to magento marketplace and sing in to your account or if you have none, then sign up and create the account.
  • Click on Access Keys in your profile. And this will take you to the area with your access keys.
  • Here you’ll see a big orange button “Create new Access Key” – click on it and it will open a modal with input form. In the input field write down you project name (like “text.com”) and click on ok. This will generate both public and private keys.
  • You will now see your access keys in table below.

Now let’s add our access keys to our magento installation.

  • Go to admin area of your store
  • There go to System -> Tools -> Web Setup Wizard
  • Then click on System Configuration and it will open the form with private and public key input.
  • Fill in the needed data by copying the access keys from magento marketplace and click save config

And voila! You should be done now and should be able to run your composer command.

Not working even though i added the keys

If you’re like me, then there will be some difficulties. If you added the access keys and it still gives you the same error then check your composer by running:
composer diagnose

In my case running this gave me this notice:

composer diagnose
Checking composer.json: FAIL
The version field is present, it is recommended to leave it out if the package is published on Packagist.
Defining autoload.psr-0 with an empty namespace prefix is a bad idea for performance
require.composer/composer : unbound version constraints (@alpha) should be avoided
Checking platform settings: OK
Checking git settings: OK
Checking http connectivity to packagist: OK
Checking https connectivity to packagist: OK
Checking github.com rate limit: OK
Checking disk free space: OK
Checking pubkeys:
Tags Public Key Fingerprint: xxxxxxxx xxxxxxxx xxxxxxx xxxxxxx
Dev Public Key Fingerprint: xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxx
OK
Checking composer version: FAIL
You are not running the latest stable version, run `composer self-update` to update (1.0.3 => 1.4.2)

It turned up that my composer version was old. So i simply run the next command:
composer self-update

And updated my composer to new stable version.
After it completed the update I again ran my line:

composer require phpoffice/phpexcel

And guess what – i worked! I finally installed the needed library.
I really hope this little post helps some one whose composer is not playing along.

Cheers!

Categories
Blog Magento

Magento 1 redirect to home page after login

Hi,
I had to do a simple redirect to home page after customer is logged in, instead of him going to customer account page. The way you do it is using an observer. Magento 1 has an event that fires after login is completed, and this is the event that we’d need. First change the customer settings in system configuration, set Redirect Customer to Account Dashboard after Logging in to No (it’s in the System->Configuration->Customer->Customer Configuration section).

Then make a small extension or if you already have made one add this part in the config.xml:


...
<frontend>
    <events>
        <observers>
            <controller_action_postdispatch_customer_account_loginPost>
                 <my_login_redirect>
                        <type>singleton</type>
                        <class>my_extension/observer</class>
                        <method>homeRedirect</method>
                 </my_login_redirect>
            </controller_action_postdispatch_customer_account_loginPost>
        </observers>
    </events>
</frontend>
...

This is the first part. We need to catch the event that signifies that login is finished, so we catch Magento’s controller postdispatch event on loginPostAction. Now we do the observer part that actually redirects our customer:

<?php
class My_Extension_Model_Observer{
    
    public function homeRedirect(Varien_Event_Observer $observer){
            Mage::app()->getResponse()->setRedirect(Mage::getUrl());
    }
}

And voila! Your customer will now be redirected to the home after he logs in. I will put the small extension for download later on.

Cheers 🙂

Categories
Blog Kannel

DLRs queueing in Kannel after being injected in http smsc

Hi,
we are currently working on a kannel system that is using two kannel instances with two sqlbox instances and an php http router in the middle.

client –> opensmppbox –> sqlbox1 –> bearerbox1 –> http-router –> smsbox2 –> sqlbox2 –> bearerbox2 –> smsc

We’ve done everything according to the book. Made several adjustments along the way to fasten things up. And all was working nicely until our client got a higher traffic from his smpp client and our supplier failed to deliver some dlrs. He later delivered them via cms file but they never went through our kannel system. All of a sudden the traffic got slow, and dlrs started queuing up. Since we did a whole system revamp at that time we though that it was due to configuration. So we tried several things in order to get it fixed. At the end i found this post:
https://www.mail-archive.com/users@kannel.org/msg30978.html

It turned out to be a problem in dlr tables. I didn’t set the indexes in dlr tables since they were created by the kannel and opensmppbox. Well, the second i set the indexes on dlr tables, traffic started flowing again.

So tip of the day:

HAVE YOUR TABLES INDEXED. DLR TABLES SHOULD HAVE TS AND URL FIELDS SET AS INDEXES.

I hope this helps someone.

Categories
Plugins Wordpress

Weather plugin

When Proodos was starting, we decided to develop a small wordpress plugin that would show the current conditions in our town. The plugin development started in 2013. but was stopped because of other obligations and the design of our webpage was changed so it didn’t include the plugin. This year we restarted the plugin development, and we’re finally ready to launch the first version.

Installation and settings

You can install plugin manually by:
1. copy it in plugin folder of your wordpress and extract there or
2. go to plugins area in administration, go to add new plugin, and click on upload plugin. Choose the downloaded zip file and click on upload.

After installation please make sure to setup the plugin in settings area. To show plugin on your page simply echo pdsWeather() in the designated place.

update: You can now go to widgets area in your sites administration and drag & drop the plugin to the widget area of your choice.

Versions

Version 3.1
– removed printt of the results after save
– tested on 4.5
– implement selective refresh for widget

Version 3.0
– solved more bugs
– add input field for API key to the settings area
– made sure that api key is required in order for widget to be shown
– added drag & drop widget in widgets secions

Version 2.0
– solved some bugs
– added input field for API key
– added uninstall functions
– show weather label yes/no

Version 1.1.1
-another little bug solved

version 1.1
– solving bugs
– added temperature signs (F & °C)

Version 1.0. includes:
– current conditions at setup location every hour
– show/hide conditions string
– show/hide feels like string
– show temperature(s) in degrees celsius or fahrenheit, or both
– show/hide icon
– choose between icons provided from weather underground or use weather font by erik flowers

Planned changes for version 3.x:
– current conditions checkup frequency setup

If you have some other things that you would like to include first, please write to us.

Legal

The plugin uses Weather underground API for checkup of weather conditions. It also includes weather icons font developed by Erik Flowers.

Download

The plugin is now approved by WordPress team and is hosted on wordpress svn, o you can simply go to plugins section of your WordPress site, click add new and search for Weather
or you can download the plugin from wordpress page:
pdsweather

And here/s the official wordpress pdsweather page:
weather

Bugs

Please let us know if you find any bugs.

Categories
Blog Tidbits

Testing the candidates

Hello,
for all those who sent us their CV’s before and on 27th May 2015. we’d like you to solve one of the two tests and bring the answer to your job interview.

1. Html/CSS test

Please download the zip file containing the materials. Then do the simple html/css web page with those materials. Doesn’t need to be fancy, just give us your idea so we can see what you know. Also HTML5 use is a bonus.
Download link: testing materials

2. Backend test

Write a code snippet that prints out (echoes) numbers from 0-100. For every number that is divisible with 3 write “three”, for every number divisible with 5 write “five”. The last number write in words on language of your choice. Please take care that there are numbers divisible with 5 and 3. You can solve this test via pseudocode, c++, php, javascript or any other programming language.

As you can see the tests are not hard to solve. Even if you don’t solve them come to your job interview.

See you on your job interview. 🙂

Categories
Blog Tidbits

We’re looking for new apprentices

Hello!

If you want to learn web programming, here’s your chance! We’re looking for two apprentices to learn and work with us here in Osijek. These are the terms:

  • know how to use computer
  • foreign language (english, german, etc…) at least basic knowledge
  • be willing to use that foreign language, no matter your knowledge of it, in daily communication
  • have a degree from university – bacc., or mag., or ing., or dipl. ing., whatever
  • have no work experience

If you satisfy all of the terms, then contact us.

and here the link to official job offering: http://burzarada.hzz.hr/RadnoMjesto_Ispis.aspx?WebSifra=70046669

Cheers! 🙂

Categories
Blog Magento

Magento “Wrong tab configuration ….”

I made myself this problem today, and lost a half an hour trying to figure out what was wrong. So I decided to write a blog post about it, just so I don’t forget.

I had to add new tab to order view in admin area of Magento. I did everything by the book, but for some reason, when I refreshed the order view I got an error report screen. And the report said:

a:5:{i:0;s:24:”Wrong tab configuration.”;i:1;s:2023:”#0 [internal function]: Mage_Adminhtml_Block_Widget_Tabs->addTab(‘user_upload_ima…’, ‘mymodule/sale…’)

Whaaaat?!?!?! But, but, but…. I’ve set up everything correctly! Then next half an hour I was changing this and that before I decided to open Mage_Adminhtml_Block_Widget_Tabs and put echo “here” in various places in function addTab. At the end I saw that when I dumped the $tab variable it was:

boolean(false)

So I remembered. I didn’t have any blocks defined in this module prior to this one – have I even set up block class in my config.xml? I checked the config.xml and of course there was no block class setup.

So to solve the error. all I had to do is add this to my config.xml file:

<global>
    ....
    <blocks>
            <mymodule>
                <class>My_Module_Block</class>
            </mymodule>
     </blocks>
     .....
</global>

Cheers 🙂

Categories
Blog Magento

Magento 1.9.1.0 and 500 Internal server error

HI,
we recently begun working on a web shop whose owner wanted color swatch option for her store. We felt very lucky that Magento CE 1.9.1 came with that functionality. So we upgraded store from 1.9.0.1 to 1.9.1.0 But as usual, Magento upgrade didn’t go without problems. After the upgrading was finish, we coldn’t open the store. All we saw was a blank screen with 500 Internal server error displayed.

We tried making a downgrade back to 1.9.0.1. and then again upgrade to 1.9.1.0 As soon as we downgraded the store it was working normally. But the minute we upgraded it, it again displayed error 500. This only ment that there was something wrong with Magento installation. After looking at the server logs, we found out the problem – permissions on index.php. The permissions on index.php were set to 664 meaning the group was able to write to the file. The minute we changed the permissions on index.php to 644 the store was working again.

Hope this helps 🙂

Categories
Blog Magento

Setting template for static blocks in Magento footer

Hi!
Today I had a task to insert static blocks into footer area of Magento web page. Since there are some troubles with WYSIWYG editor and html code I opted to make it more secure for future editing so I wanted to give the static blocks their template. I’m guessing that you know how to add static block into footer area. (Hint! Add it in local.xml).
In order for static blocks to be able to have template you have to call them as a type cms/widget_block instead of cms/block. This will allow your blocks to have template because by default static blocks don’t have a template. Here’s how the footer part of my local.xml looked like:

    <reference name="footer">
      <block type="cms/widget_block" name="cms_footer_socials" template="cms/footer_area.phtml">
          <action method="setBlockId">
               <blockId>identifier</blockId>
          </action>
      </block>
    </reference>

And in my theme I added cms/footer_area.phtml that with this code. Edit it to suit your needs:

<?php 
$id = $this->getBlockId();
$block = Mage::getModel('cms/block')->load($id);
?>
<div class="block">
    <div class="title"><?php echo $block->getTitle() ?></div>
    <div class="content"><?php echo $block->getContent() ?></div>
</div>

And now my static blocks in footer area have their template 🙂 .

Categories
Blog Zend Zend 2

Ajax, ZF2 action and json return

Hi!
On the first project with Zend 2 I needed to incorporate Ajax. I made my view action, view script and in it added ajax that had set url to another action in the same controller. On the click of the button the data had to be sent via ajax and then new set of data had to be returned in form of json. Here came the problem. No matter what I did, the returned data wasn’t in json format. It contained, exept the json, the entire layout script from Zend 2. Naturally I resorted to doc Google to search for remedy to my problems.
I didn’t find much, expect the way to incorporate Json view. But after some time I gave up on the idea – didn’t seem really practical. I just wanted something simple and quick. During my search I stumbled upon the advice to get response and set its content. So I tried it and it worked!

Here is the simplest way to set json as your response:

    // some controller

   public function myajaxAction(){
    //....parsing of the received data

    $return=$object->fetchData();

    return $this->getResponse()->setContent(json_encode($return));
  }

Voila! 🙂