EzDevInfo.com

zend-framework interview questions

Top zend-framework frequently asked interview questions

Adding values to a magento dropdown or multi-select product attribute while adding a new product

I'm wondering if anyone has found or written an extension that would allow a magento website administrator the ability to add values to their products attribute while adding the product. For example, if I sell books and want the book author to be in a drop down list so that it would be used in layered navigation, it seems odd that I would have to add the author via the attributes section before adding the product. From a workflow standpoint it really makes sense to have an "add new value" button next to the drop down on my add product screen.

Anyone have any thoughts or insight?


Source: (StackOverflow)

Running a Zend Framework action from command line

I would like to run a Zend Framework action to generate some files, from command line. Is this possible and how much change would I need to make to my existing Web project that is using ZF?

Thanks!


Source: (StackOverflow)

Advertisements

How do you make Zend Framework NOT render a view/layout when sending an AJAX response?

Zend's documentation isn't really clear on this.

The problem is that, by default, Zend automatically renders a view at the end of each controller action. If you're using a layout - and why wouldn't you? - it also renders that. This is fine for normal Web pages, but when you're sending an AJAX response you don't want all that. How do you prevent Zend from auto-rendering on an action-by-action basis?


Source: (StackOverflow)

How can I get the current action in Zend Framework?

I have a plugin in my Zend Framework application that checks login status after every request, and reroutes the user to the login action if their session is invalid or expired. I would like to cache the previous request action so that, after a successful login attempt, I can redirect them back to their previous request.

I have found the documentation on the setActionController() method, but I can't find anything on a "getActionController()" method. Does one exist? If so, does anyone have any information they could link me to on it? If not, what's the best way to achieve my goal?


Source: (StackOverflow)

Registering Zend Database Adapter in Registry

I am looking to register a reference to the main Database Adapter in the Registry during Bootstrapping so it can be used elsewhere in my site (specifically the Authorisation action).

I have implemented an ugly fix where i create a Database Table object and call the getAdapter() method on it and pass through that. However, this is a bad way of doing it and I would like it to be available via the registry.

Does anyone know how to do this? Any help or pointers in the right direction are appreciated!

Cheers Stuart

Ps. Im using Zend Framework 1.8.


Source: (StackOverflow)

Zend Framework 1 vs Zend Framework 2 performance [closed]

Zend Framework 2 was just released and Zend offers support for ZF1 for only 18 months from now. I know they were working for new features in ZF2 and then they were going to do some major speed improvements to it since it was 5 times slower than ZF1.

I would like to know how slower is ZF2 than ZF1 from benchmarks or tests you did and not pure speculation.

The latest benchmark I found is from February 22, 2012 and it concludes that ZF2 is 4 times slower than ZF1.

Link here


Source: (StackOverflow)

How to create WHERE IN clause with Zend_Db_Select

So I am trying to accomplish something like this:

SELECT * FROM table WHERE status_id IN (1,3,4);

using Zend_Db_Select... can't find how to do it :( Is it at all possible?


Source: (StackOverflow)

What is the difference between redirect and forward in Zend framework

What is the difference between redirect and forward in Zend framework?

When we should use redirect and when should we use forward?


Source: (StackOverflow)

How do I use PHPUnit with Zend Framework?

I would like to know how to write PHPUnit tests with Zend_Test and in general with PHP.


Source: (StackOverflow)

Starting with Zend Tutorial - Zend_DB_Adapter throws Exception: "SQLSTATE[HY000] [2002] No such file or directory"

i start learning Zend Framework with the Book "Zend Framework in Action" in German.

Right there where it start to get interesting my PHP Unit Test throws this Error: "Zend_Db_Adapter_Exception: SQLSTATE[HY000] [2002] No such file or directory"

I cant find any hints at google. I did everything like in the book. Can anyone give me a hint where to search my fault?

Is this a usual beginner mistake?


Source: (StackOverflow)

Zend Framework: How do I remove the decorators on a Zend Form Hidden Element?

I'm trying to remove the default decorators on a hidden form element. By default, the hidden element is displayed like this:

<dt>Hidden Element Label (if I had set one)</dt>
<dd><input type="hidden" name="foobar" value="1" id="foobar"></dd>

I don't want my hidden element to take up space on my page. I want to remove all the default decorators so all I'm left with is the input tag.

<input type="hidden" name="foobar" value="1" id="foobar">

How can I achieve this?


Source: (StackOverflow)

How to switch layout files in Zend Framework?

I'm sure it's a simple one-liner, but I can't seem to find it.

How can I use a different layout file for a particular action?

Update: This worked for me, thanks!

// Within controller
$this->_helper->_layout->setLayout('other-layout') //other-layout.phtml

//Within view script
<?php $this->layout()->setLayout('other-layout'); ?>

Source: (StackOverflow)

Sending variables to the layout in Zend Framework

In my project I have a number of dynamic elements that are consistently on every page. I have put these in my layout.phtml

My question is: How can I send variables into my layout from my controllers?

If I want to send things from my controller I can use:

$this->view->whatever = "foo";

And receive it in the view with

echo $this->whatever;

I cannot figure out how to do the same with my layout. Perhaps there is a better way around the problem?


Source: (StackOverflow)

How can I make email template in Zend Framework?

I want to make email templates in Zend Framework.

For example,

<html>
<body>
Dear {$username$},<br>
This is a invitation email sent by your {$friend$}.<br>
Regards,<br>
Admin
</body>
</html>

I want to make this file, get it in Zend framework, set those parameters (username, friend) and then send the email.

How can I do that? Does Zend support this?


Source: (StackOverflow)

How to print exact sql query in zend framework ?

I have the following piece of code which i taken from model,

    ...
                  $select = $this->_db->select()
                    ->from($this->_name)
                    ->where('shipping=?',$type)
                    ->where('customer_id=?',$userid);
                 echo  $select; exit; // which gives exact mysql query.
            .....

When i use update query in zend like ,

$up_value = array('billing'=> '0');
$this->update($up_value,'customer_id ='.$userid.' and address_id <> '.$data['address_Id']);      

Here i want to know the exact mysql query. Is there any possible way to print the mysql query in zend ? kindly advice


Source: (StackOverflow)