install script not working magento 1.9 - php

first step disabled the cache... done...
below is my file hierarchy:
this is my config.xml at app/code/community/Foggyline/HappyHour/etc/config.xml
<?xml version="1.0"?>
<config>
<modules>
<Foggyline_HappyHour>
<version>1.0.0.0</version>
</Foggyline_HappyHour>
</modules>
<frontend>
<routers>
<foggyline_happyhour>
<use>standard</use>
<args>
<module>Foggyline_HappyHour</module>
<frontName>happyhour</frontName>
</args>
</foggyline_happyhour>
</routers>
</frontend>
<global>
<blocks>
<foggyline_happyhour>
<class>Foggyline_HappyHour_Block</class>
</foggyline_happyhour>
</blocks>
<models>
<foggyline_happyhour>
<class>Foggyline_HappyHour_Model</class>
<resourceModel>foggyline_happyhour_resource</resourceModel>
</foggyline_happyhour>
<foggyline_happyhour_resource>
<class>Foggyline_HappyHour_Model_Resource</class>
<entities>
<user>
<table>foggyline_happyhour_user</table>
</user>
</entities>
</foggyline_happyhour_resource>
</models>
<resources>
<foggyline_happyhour_setup>
<setup>
<model>Foggyline_HappyHour</model>
</setup>
<connection>
<use>core_setup</use>
</connection>
<foggyline_happyhour_write>
<connection>
<use>core_write</use>
</connection>
</foggyline_happyhour_write>
<foggyline_happyhour_read>
<connection>
<use>core_read</use>
</connection>
</foggyline_happyhour_read>
</foggyline_happyhour_setup>
</resources>
</global>
</config>
and my install script at app/code/community/Foggyline/HappyHour/sql/foggyline_happyhour_setup/install-1.0.0.0.php
and also tried renaming the install-1.0.0.0.php to mysql4-install-1.0.0.0.php but not woring..
/* #var $installer Mage_Core_Model_Resource_Setup */
$installer = $this;
$installer->startSetup();
$table = $installer->getConnection()
->newTable($installer->getTable('foggyline_happyhour/user'))
->addColumn('user_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
'identify' => true,
'unsigned' => true,
'nullable' => false,
'primary' => true)
, 'Id')
->addColumn('first_name', Varien_Db_Ddl_Table::TYPE_VARCHAR, null, array(
'nullable' => false
)
, 'First Name')
->addColumn('last_name', Varien_Db_Ddl_Table::TYPE_VARCHAR, null, array(
'nullable' => false
)
, 'Last Name')
->setComment('Foggyline_HappyHour User Entity');
$installer->getConnection()->createTable($table);
$installer->endSetup();
now when i refesh my store or visit any page of my store.. nothing is getting into mysql.. the core_resource table does not have any entry as foggyline_happyhour_setup with version 1.0.0.0 , i also tried clearing cache /var/cache any help or suggestion would be a great help thanks in advance...
i am new to magento.. and still learning it.. so that i could become a magento developer...

Please add read and write permission for resource.
<resources>
<foggyline_happyhour_setup>
<setup>
<module>Foggyline_HappyHour</module>
</setup>
<connection>
<use>core_setup</use>
</connection>
</foggyline_happyhour_setup>
<foggyline_happyhour_write>
<connection>
<use>core_write</use>
</connection>
</foggyline_happyhour_write>
<foggyline_happyhour_read>
<connection>
<use>core_read</use>
</connection>
</foggyline_happyhour_read>
Now you need to remove resource entry from core_resource and then remove cache and try to check.

Check that you dont have the node <skip_process_modules_updates>1</skip_process_modules_updates> in your local.xml

Had this problem too
2016-03-14T19:50:08+00:00 ERR (3): Warning: simplexml_load_string(): resourceModel>
Had a newline in the config.xml after
</resourceModel
So, check everything for spaces and newlines. And... Enable magento logs and verbose errors on index.php.
Another thing. When you remove the core_resource table entry, be sure to delete foggyline_happyhour_user too... If not you will get a There has been an error processing your request.

Please change <model>Foggyline_HappyHour</model> to <module>Foggyline_HappyHour</module>.
Their documentation is also wrong.

Related

Magento 1.9 : sql script is not running

Basically what i am trying to do : I want some custom attributes for Customer entity. And to add those fields in db i am executing script.
I tried lots & lots of tweaks , methods but i cant solve SQL script error.
The important thing in it is : It makes entry in core_resource table.
My script made entry in core_resource.
I made extension according to this Alan storm Site .
Any help is highly appreciated.
My extension structure
Here is my coding part.
Config file of module
<?xml version="1.0"?>
<config>
<modules>
<StackExchange2_Customer>
<version>0.1.0</version>
</StackExchange2_Customer>
</modules>
<global>
<resources>
<stackExchange2_customer_setup>
<setup>
<module>StackExchange2_Customer</module>
<class>StackExchange2_Customer_Model_Resource_Mysql4_Setup</class>
<!-- <class>StackExchange2_Customer_Sql</class>-->
</setup>
<!--Mew node-->
<connection>
<use>core_setup</use>
</connection>
</stackExchange2_customer_setup>
<!--as per sOverflow-->
<stackExchange2_customer_write>
<connection>
<use>core_write</use>
</connection>
</stackExchange2_customer_write>
<stackExchange2_customer_read>
<connection>
<use>core_read</use>
</connection>
</stackExchange2_customer_read>
</resources>
</global>
</config>
Setup.php
<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
//Mage_Eav_Model_Entity_Setup
class StackExchange2_Customer_Model_Resource_Mysql4_Setup extends Mage_Core_Model_Resource_Setup{
}
mysql4-install-0.1.0.php
<?php
//echo "in script";die;
$installer = $this;
echo "hi123";
$installer->startSetup();
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
//attr1
$installer->addAttribute('customer','name_of_child', array(
'type' => 'varchar',
'label' => 'Name of child',
'input' => 'text',
'position' => 120,
'required' => false,//or true
'is_system' => 0,
));
$attribute1 = Mage::getSingleton('eav/config')->getAttribute('customer', 'name_of_child');
//
$attribute1->setData('used_in_forms', array(
'adminhtml_customer',
'checkout_register',
'customer_account_create',
'customer_account_edit',
));
//
$attribute1->setData('is_user_defined', 0);
//
$attribute1->save();
Mage::log(__FILE__ . 'Update installed.');
$installer->endSetup();
Any help is highly appreciated
NOTE : In localhost it gives error : Am I using wrong class or anything missing?
( ! ) Fatal error: Call to undefined method StackExchange2_Customer_Model_Resource_Mysql4_Setup::addAttribute() in D:\xampp\htdocs\mykidscare\app\code\local\StackExchange2\Customer\sql\stackexchange2_customer_setup\mysql4-install-0.1.0.php on line 12
Add the following.
<resources>
<stackExchange2_customer_setup>
<setup>
<module>StackExchange2_Customer</module>
<class>Mage_Eav_Model_Entity_Setup</class>
</setup>
<connection>
<use>core_setup</use>
</connection>
</stackExchange2_customer_setup>
<stackExchange2_customer_write>
<connection>
<use>core_write</use>
</connection>
</stackExchange2_customer_write>
<stackExchange2_customer_read>
<connection>
<use>core_read</use>
</connection>
</stackExchange2_customer_read>
</resources>
You need to add Mage_Eav_Model_Entity_Setup class in setup in order to add any attribute.
Finally i solved it :) .
NOW it works after extending proper class (Mage_Customer_Model_Entity_Setup).
class StackExchange2_Customer_Model_Resource_Mysql4_Setup extends Mage_Customer_Model_Entity_Setup{
}

Add column script not working correctly in Magento

I have some trouble in Magento sql updating table. I create extension and I would like to add some new columns to existing table 'customer_group'.
<modules>
<Module_Name>
<module>1.0.0</module>
</Module_Name>
</modules>
<global>
<models>
<module_name>
<class>Module_Name_Model</class>
<resourceModel>module_name_resource</resourceModel>
</module_name>
<module_name_resource>
<class>Module_Name_Model_Resource</class>
</module_name_resource>
</models>
<resources>
<module_name_setup>
<setup>
<module>Module_Name</module>
<class>Module_Name_Model_Resource_Setup</class>
</setup>
</module_name_setup>
</resources>
</global>
In sql/module_name_setup/mysql4-install-1.0.0.php I have this code:
$installer = $this;
$connection = $installer->getConnection();
$installer->startSetup();
$installer->getConnection()
->addColumn($installer->getTable('customer/customer_group'), 'column_one', array(
'TYPE' => Varien_Db_Ddl_Table::TYPE_TEXT,
'NULLABLE' => false,
'COMMENT' => 'Column One'
))
->addColumn($installer->getTable('customer/customer_group'), 'column_two', array(
'TYPE' => Varien_Db_Ddl_Table::TYPE_TEXT,
'NULLABLE' => false,
'COMMENT' => 'Column Two'
));
$installer->endSetup();
But when I refresh Magento frontend page I didn't saw in core_resources table any changes and in customer_group these two columns didn't exist.
What I do wrong?
Thanks!
For what it's worth, this is how I do a install script:
Place the install script at:
Company/Module/sql/your_module_setup/install-1.0.0.0.php
And in the etc/config.xml of the module:
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<Company_Module>
<version>1.0.0.0</version>
</Company_Module>
</modules>
<global>
<resources>
<your_module_setup>
<setup>
<module>Company_Module</module>
<class>Company_Module_Model_Resource_Setup</class>
</setup>
</your_module_setup>
</resources>
</global>
</config>
Then make create the file Company/Module/Model/Resource/Setup.php:
<?php
class Company_Module_Model_Resource_Setup extends Mage_Sales_Model_Resource_Setup
{
}
I've solve this bug. I forgot to set version in app/etc/Module_Name.xml, it should be
<modules>
<Module_Name>
<active>true</active>
<codePool>local</codePool>
<depends>
<Mage_Shipping/>
</depends>
<version>1.0.0</version>
</Module_Name>
</modules>
and in config.xml version should be set too

Magento - Issue with creating a custom Module

I'm using Magento 1.9.1 and i'm trying to create a module which is giving a 50% discount from the grand total.
Here is my code:
/app/code/local/VivasIndustries/PercentPayment/etc/config.xml :
<?xml version="1.0"?>
<config>
<modules>
<VivasIndustries_PercentPayment>
<version>0.1.0</version>
</VivasIndustries_PercentPayment>
</modules>
<global>
<sales>
<quote>
<totals>
<discount>
<class>VivasIndustries_PercentPayment_Model_Discount</class>
<after>subtotal</after>
</discount>
</totals>
</quote>
<order_invoice>
<totals>
<discount>
<class>VivasIndustries_PercentPayment_Model_Invoice</class>
<after>subtotal</after>
</discount>
</totals>
</order_invoice>
<order_creditmemo>
<totals>
<discount>
<class>VivasIndustries_PercentPayment_Model_Creditmemo</class>
<after>subtotal</after>
</discount>
</totals>
</order_creditmemo>
</sales>
</global>
</config>
/app/code/local/VivasIndustries/PercentPayment/controllers/IndexController.php :
<?PHP
class VivasIndustries_PercentPayment_Model_Discount extends Mage_Sales_Model_Quote_Address_Total_Abstract {
public function collect(Mage_Sales_Model_Quote_Address $address) {
if ($address->getData('address_type') == 'billing')
return $this;
$discount = 50; //your discount percent
$grandTotal = $address->getGrandTotal();
$baseGrandTotal = $address->getBaseGrandTotal();
$totals = array_sum($address->getAllTotalAmounts());
$baseTotals = array_sum($address->getAllBaseTotalAmounts());
$address->setFeeAmount(-$totals * $discount / 100);
$address->setBaseFeeAmount(-$baseTotals * $discount / 100);
$address->setGrandTotal($grandTotal + $address->getFeeAmount());
$address->setBaseGrandTotal($baseGrandTotal + $address->getBaseFeeAmount());
return $this;
}
public function fetch(Mage_Sales_Model_Quote_Address $address) {
if ($address->getData('address_type') == 'billing')
return $this;
$amt = $address->getDiscountAmount();
if ($amt != 0) {
$address->addTotal(array(
'code' => 'Discount',
'title' => 'Discount',
'value' => $amt
));
}
return $address;
}
}
?>
/app/etc/modules/VivasIndustries_PercentPayment.xml :
<?xml version="1.0"?>
<config>
<modules>
<VivasIndustries_PercentPayment>
<active>true</active>
<codePool>local</codePool>
</VivasIndustries_PercentPayment>
</modules>
</config>
This are all files which i've created for my new module. All what i've done.
I was using this guide: http://magento.ikantam.com/qa/how-add-discount-total-magento
Now when i try to open my checkout page i got error - There has been an error processing your request
When i open my error_log i can see this thing:
[09-Nov-2014 18:22:35 UTC] CSRF state token does not match one provided.
Can you please help me fix this problem and make my new Module works like intended ?
Thanks in advance!
Modifying total is always difficult part. And it's hard find out the problem in your code unless I have set up of that module in my system. Anyway here I have shared some codes for modifying total during checkout process. I explained as much I can.
For this you have to update lot of things. Quote, Address, Order, Creditmemo , Invoice, shipping, multi shipping etc. Okay here we go,
First we need to create our configuration file that's called config.xml,
config.xml
Update:
<config>
<modules>
<VivasIndustries_PercentPayment>
<version>0.1.0</version>
</VivasIndustries_PercentPayment>
</modules>
<global>
<helpers>
<percentpayment>
<class>VivasIndustries_PercentPayment_Helper</class>
</percentpayment>
</helpers>
<models>
<percentpayment>
<class>VivasIndustries_PercentPayment_Model</class>
<resourceModel>percentpayment_mysql4</resourceModel>
</percentpayment>
</models>
<resources>
<salesattribute1416562342_setup>
<setup>
<module>VivasIndustries_PercentPayment</module>
<class>Mage_Sales_Model_Mysql4_Setup</class>
</setup>
<connection>
<use>core_setup</use>
</connection>
</salesattribute1416562342_setup>
<salesattribute1416562342_write>
<connection>
<use>core_write</use>
</connection>
</salesattribute1416562342_write>
<salesattribute1416562342_read>
<connection>
<use>core_read</use>
</connection>
</salesattribute1416562342_read>
</resources>
<events>
<checkout_type_onepage_save_order_after> <!-- identifier of the event we want to catch -->
<observers>
<checkout_type_onepage_save_order_after_discount_handler> <!-- identifier of the event handler -->
<type>model</type> <!-- class method call type; valid are model, object and singleton -->
<class>percentpayment/newordertotalobserver</class> <!-- observers class alias -->
<method>saveDiscountTotal</method> <!-- observer's method to be called -->
<args></args> <!-- additional arguments passed to observer -->
</checkout_type_onepage_save_order_after_discount_handler>
</observers>
</checkout_type_onepage_save_order_after>
<checkout_type_multishipping_create_orders_single> <!-- identifier of the event we want to catch -->
<observers>
<checkout_type_multishipping_create_orders_single_discount_handler> <!-- identifier of the event handler -->
<type>model</type> <!-- class method call type; valid are model, object and singleton -->
<class>percentpayment/newordertotalobserver</class> <!-- observers class alias -->
<method>saveDiscountTotalForMultishipping</method> <!-- observer's method to be called -->
<args></args> <!-- additional arguments passed to observer -->
</checkout_type_multishipping_create_orders_single_discount_handler>
</observers>
</checkout_type_multishipping_create_orders_single>
</events>
<sales>
<quote>
<totals>
<discount_total>
<class>percentpayment/quote_address_total_discount</class>
<after>subtotal,freeshipping,tax_subtotal,shipping</after>
<before>grand_total</before>
</discount_total>
</totals>
</quote>
<order_invoice>
<totals>
<discount_total>
<class>percentpayment/order_invoice_total_discount</class>
<after>subtotal,freeshipping,tax_subtotal,shipping</after>
<before>grand_total</before>
</discount_total>
</totals>
</order_invoice>
<order_creditmemo>
<totals>
<discount_total>
<class>percentpayment/order_creditmemo_total_discount</class>
<after>subtotal,freeshipping,tax_subtotal,shipping</after>
<before>grand_total</before>
</discount_total>
</totals>
</order_creditmemo>
</sales>
</global>
</config>
change other things as per this configuration. before that go to your database using phpmyadmin open core_resources table. and delete your module entry if it is there. that's it.
Please comment here, if you have any doubt.

Fatal error: Call to a member function toHtml() on a non-object

I have custom module jewellery. Tabs used in the admin form in category edit. Below code is used to add tabs in the admin form. it give fatal error
Fatal error: Call to a member function toHtml() on a non-object in D:\wamp\www\avita\app\code\local\Mage\Adminhtml\Block\Catalog\Category\Tabs.php on line 158
Below are my files
1.) local/Mage/Adminhtml/Block/Catalog/Category/Tabs.php
$this->addTab('upload_prices', array(
'label' => Mage::helper('catalog')->__('Upload prices'),
'content' => $this->getLayout()->createBlock('jewellery/adminhtml_catalog_category_product_tab')->toHtml(),
));
2.app/code/local/Subora/Jewellery/etc/config.xml
<?xml version="1.0"?>
<config>
<modules>
<Subora_Jewellery>
<version>0.1.0</version>
</Subora_Jewellery>
</modules>
<global>
<models>
<jewellery>
<class>Subora_Jewellery_Model</class>
</jewellery>
</models>
<helpers>
<jewellery>
<class>Subora_Jewellery_Helper</class>
</jewellery>
</helpers>
<blocks>
<jewellery>
<class>Subora_Jewellery_Block</class>
</jewellery>
</blocks>
<resources>
<jewellery_setup>
<setup>
<module>Subora_Jewellery</module>
</setup>
<connection>
<use>core_setup</use>
</connection>
</jewellery_setup>
<jewellery_write>
<connection>
<use>core_write</use>
</connection>
</jewellery_write>
<jewellery_read>
<connection>
<use>core_read</use>
</connection>
</jewellery_read>
</resources>
</global>
<adminhtml>
<layout>
<updates>
<jewellery>
<file>jewellery.xml</file>
</jewellery>
</updates>
</layout>
<events>
<adminhtml_catalog_product_edit_prepare_form>
<observers>
<jewellery_product_edit_prepare_form>
<class>jewellery/observer</class>
<method>productEditPrepareForm</method>
</jewellery_product_edit_prepare_form>
</observers>
</adminhtml_catalog_product_edit_prepare_form>
<catalog_product_save_after>
<observers>
<jewellery_save_product_data>
<type>singleton</type>
<class>jewellery/observer</class>
<method>saveProductTabData</method>
</jewellery_save_product_data>
</observers>
</catalog_product_save_after>
<catalog_category_save_after>
<observers>
<jewellery_save_category_data>
<type>singleton</type>
<class>jewellery/observer</class>
<method>saveCategoryTabData</method>
</jewellery_save_category_data>
</observers>
</catalog_category_save_after>
</events>
</adminhtml>
</config>
3 app\design\frontend\base\default\layout\jewellery.xml
<?xml version="1.0"?>
<layout version="0.1.0">
<jewellery_adminhtml_jewellerybackend_index>
<reference name="content">
<block type="jewellery/adminhtml_jewellerybackend" name="jewellerybackend"/>
</reference>
</jewellery_adminhtml_jewellerybackend_index>
<jewellery_adminhtml_jewellerybackend_save>
<reference name="content">
<block type="jewellery/adminhtml_jewellerybackend_save" name="jewellerybackend_save" template="jewellery/jewellerybackend.phtml" />
</reference>
</jewellery_adminhtml_jewellerybackend_save>
<adminhtml_catalog_product_edit>
<reference name="product_tabs">
<action method="addTab">
<name>subora_jewellery_tab</name>
<block>jewellery/adminhtml_catalog_product_tab</block>
</action>
</reference>
</adminhtml_catalog_product_edit>
<adminhtml_catalog_product_new>
<reference name="product_tabs">
<action method="addTab">
<name>subora_jewellery_tab</name>
<block>jewellery/adminhtml_catalog_product_tab</block>
</action>
</reference>
</adminhtml_catalog_product_new>
</layout>
4.local\Subora\Jewellery\Block\Adminhtml\Catalog\Category\Product\Tab.php
<?php
class Subora_Jewellery_Block_Adminhtml_Catalog_Category_Product_Tab extends Mage_Adminhtml_Block_Widget_Form
{
protected function _prepareForm() {
$form = new Varien_Data_Form();
$this->setForm($form);
$fieldset = $form->addFieldset('category_import_prices', array('legend'=>Mage::helper('catalog')->__('Import prices')));
$fieldset->addField('prices', 'file', array(
'label' => Mage::helper('catalog')->__('Prices file (CSV only)'),
'name'=> 'prices',
));
return parent::_prepareForm();
}
}
Now what to do i have tried but cant add tab??
The problem persists here
$this->getLayout()->createBlock('jewellery/adminhtml_catalog_category_product_tab')->toHtml();
toHtml() is calling in a non-object means, createBlock('jewellery/adminhtml_catalog_category_product_tab') is not working correctly. createBlock() is used to create a new block and add it to the layout. This function has 3 parameters.
type 2. name 3. attributes
you have specified type as jewellery/adminhtml_catalog_category_product_tab. SO magento will look for app/code/local/Subora/Jewellery/Block/Adminhtml/Catalog/Category/Product/Tab.ph‌​p and the file should be properly declared.
Next, you need to specify a block name. It is necessary. Magento needs all blocks has unique names. Name is absent here.
Next parameter is attribute. It is optionnal. You can set a template by using this parameter. So you can try this code.
$this->getLayout()->createBlock(
'jewellery/adminhtml_catalog_category_product_tab',
'jewellery.tab',
array('template' => 'your/template.phtml') //if any
)->toHtml();
EDIT
First you need to ensure, your module is active or not. You can do this via admin. System > Configuration > Advanced. Check your module is active there.
Next thing is, your layout file is in wrong postion. jewellery.xml is an admin layout file. It should reside in app\design\adminhtml\default\default\layout\jewellery.xml instead of app\design\frontend\base\default\layout\jewellery.xml

Magento redirect from adminthtml page to a frontend action

Following this post I've finally managed to capture an event by extending the Magento_Adminhtml_Controller_Action and carry out some actions before it. But now I'm trying to improve it so I can capture another event triggered on the admin panel and from there pass an array through the request variable to another event on the frontend. I've these SO questions/answers, here and here but no way I can achieve what I need. I've tested the observer code using die() to be sure that the execution thread goes into the correct call and it is ok. I'm using the CommerceBug from AlanStorm, in case it can be used to get some light on this issue.
This is my Observer.php code.
<?php
class Dts_Videotestimonials_Model_Observer {
public function hookToAdminhtmlControllerActionPreDispatch($observer)
{
if($observer->getEvent()->getControllerAction()->getFullActionName() == 'videotestimonials_adminhtml_videotestimonialsbackend_post')
{
// dispatching our own event before action upload video is run and sending parameters we need
Mage::dispatchEvent("upload_video_before", array('request' => $observer->getControllerAction()->getRequest()));
}
}
public function hookToUploadVideoBefore($observer)
{
//Hooking to our own event
$request = $observer->getEvent()->getRequest()->getParams();
// do something with product
$user = Mage::getSingleton('admin/session');
$userName = $user->getUser()->getFirstname();
$userEmail = $user->getUser()->getEmail();
$request['product_id'] = "16"; #$_product->getId(),
$request['author_email'] = $userEmail;
$request['author_name'] = $userName;
$request['video_link'] = "http://www.youtube.com/watch?v=y435u6kfExA&feature=youtube_gdata_player";
$request['video_type'] = "link";
$request['title'] = "AT&T Phone Nokia 2610";
$request['comment'] = "this is a comment";
Mage::dispatchEvent("vidtest_youtube_post", $request);
}
}
EDITED:
Here is the full config.xml
<?xml version="1.0"?>
<config>
<modules>
<Dts_Videotestimonials>
<version>0.1.0</version>
</Dts_Videotestimonials>
</modules>
<global>
<models>
<videotestimonials>
<class>Dts_Videotestimonials_Model</class>
<resourceModel>videotestimonials_mysql4</resourceModel>
</videotestimonials>
</models>
<events>
<controller_action_predispatch>
<observers>
<controller_action_before>
<type>singleton</type>
<class>videotestimonials/observer</class>
<method>hookToAdminhtmlControllerActionPreDispatch</method>
</controller_action_before>
</observers>
</controller_action_predispatch>
<upload_video_before>
<observers>
<upload_video_before>
<type>singleton</type>
<class>videotestimonials/observer</class>
<method>hookToUploadVideoBefore</method>
</upload_video_before>
</observers>
</upload_video_before>
</events>
<helpers>
<videotestimonials>
<class>Dts_Videotestimonials_Helper</class>
</videotestimonials>
</helpers>
<blocks>
<videotestimonials>
<class>Dts_Videotestimonials_Block</class>
</videotestimonials>
</blocks>
</global>
<admin>
<routers>
<videotestimonials>
<use>admin</use>
<args>
<module>Dts_Videotestimonials</module>
<frontName>videotestimonials</frontName>
</args>
</videotestimonials>
</routers>
</admin>
<adminhtml>
<menu>
<videotestimonials module="videotestimonials">
<title>Videotestimonials</title>
<sort_order>100</sort_order>
<children>
<videotestimonialsbackend module="videotestimonials">
<title>VideoTestimonials_Admin</title>
<sort_order>0</sort_order>
<action>videotestimonials/adminhtml_videotestimonialsbackend</action>
</videotestimonialsbackend>
<pending_video translate="title">
<title>Videos pendientes</title>
<sort_order>20</sort_order>
<action>videotestimonials/adminhtml_pendingvideos/pending</action>
</pending_video>
</children>
</videotestimonials>
</menu>
<acl>
<resources>
<all>
<title>Allow Everything</title>
</all>
<admin>
<children>
<videotestimonials translate="title" module="videotestimonials">
<title>Videotestimonials</title>
<sort_order>1000</sort_order>
<children>
<videotestimonialsbackend translate="title">
<title>VideoTestimonials_Admin</title>
</videotestimonialsbackend>
<pending_video translate="title">
<title>Videos pendientes</title>
<sort_order>20</sort_order>
</pending_video>
</children>
</videotestimonials>
</children>
</admin>
</resources>
</acl>
<layout>
<updates>
<videotestimonials>
<file>videotestimonials.xml</file>
</videotestimonials>
</updates>
</layout>
</adminhtml>
<crontab>
<jobs>
<videotestimonials_videotestimonialscron>
<schedule><cron_expr>59 0 * */1 0</cron_expr></schedule>
<run><model>videotestimonials/cron::VideoTestimonialscron</model></run>
</videotestimonials_videotestimonialscron>
</jobs>
</crontab>
</config>
Here is what is happening. Your configuration of the admin controller is wrong. The proper way to include your controller in the admin section is this (you'll need to change out the module name, to match yours):
<?xml version="1.0" ?>
<config>
<modules>
<Video_Awesome>
<version>0.0.1</version>
</Video_Awesome>
</modules>
<global>
<models>
<Video_Awesome>
<class>Video_Awesome_Model</class>
<!-- No resource model used currently -->
</Video_Awesome>
</models>
<events>
<controller_action_predispatch>
<observers>
<controller_action_before>
<type>singleton</type>
<class>Video_Awesome/Observer</class>
<method>controllerActionPredispatch</method>
</controller_action_before>
</observers>
</controller_action_predispatch>
<upload_video_before>
<observers>
<Video_Awesome>
<type>singleton</type>
<class>Video_Awesome/Observer</class>
<method>uploadVideoBefore</method>
</Video_Awesome>
</observers>
</upload_video_before>
</events>
</global>
<admin>
<routers>
<adminhtml>
<!-- we are not creating our own router, but tapping into the adminhtml router -->
<args>
<modules>
<!-- Your module name, and then
the path to the controller (minus
the controllers folder name). So,
in this instance, I put the router
in a "Adminhtml" folder inside of
the controllers folder, like thus:
Video/Awesome/controllers/Adminhtml/videotestimonialsController.php -->
<Video_Awesome before="Mage_Adminhtml">Video_Awesome_Adminhtml</Video_Awesome>
</modules>
</args>
</adminhtml>
</routers>
</admin>
</config>
And, then, in your router (you don't need to call getEvent before getting the controller action):
public function controllerActionPredispatch ($observer)
{
if($observer->getControllerAction()->getFullActionName() == 'adminhtml_videotestimonials_post') {
// dispatching our own event before action upload video is run and sending parameters we need
Mage::dispatchEvent("upload_video_before", array('request' => $observer->getControllerAction()->getRequest()));
}
}
And finally, it doesn't sound as if you have a debugging setup for your Magento development. I would highly recommend one. I use PHPStorm (I don't have any stake in the company - this is not an advertisement :), and it works awesome. Set a breakpoint there to see if what the variables are.
I would also recommend using adminhtml_controller_action_predispatch_start, instead of the global controller_action_predispatch, as it will only trigger in the backend (a very, very small performance difference).
Also, as a small sidenote, I saw in your config.xml, that you were specifying menu items/acl there. You probably didn't know, but that is deprecated functionality, and those items should be put it adminhtml.xml.

Categories