I am trying to create a custom module which will capture order information each time a sales happens and will send that to a STOMP server. The idea is to create a realtime dashboard of sales events.
I've created the generic structure of the module and Magento is able to recognize it properly, but the code is not being executed. I've traced it down to the fact that Varien_Autoload cannot find my class.
My config is as follows:
app/etc/modules/PrettySecrets_SalesEvent.xml
<?xml version="1.0"?>
<config>
<modules>
<PrettySecrets_SalesEvent>
<active>true</active>
<codePool>local</codePool>
</PrettySecrets_SalesEvent>
</modules>
</config>
app/code/local/PrettySecrets/SalesEvent/etc/config.xml
<?xml version="1.0"?>
<config>
<modules>
<PrettySecrets_SalesEvent>
<version>0.0.1</version>
</PrettySecrets_SalesEvent>
</modules>
<global>
<models>
<prettysecrets_salesevent>
<class>PrettySecrets_SalesEvent_Model</class>
</prettysecrets_salesevent>
</models>
<events>
<checkout_onepage_controller_success_action>
<observers>
<prettysecrets_salesevent>
<type>singleton</type>
<class>prettysecrets_salesevent/observer</class>
<method>doStreamToNode</method>
</prettysecrets_salesevent>
</observers>
</checkout_onepage_controller_success_action>
</events>
</global>
</config>
I'm given to believe that the directory structure is extremely important for Magento:
app
code
local
PrettySecrets
SalesEvent
etc
config.xml
Model
Observer.php
The system.log shows:
Warning: include(PrettySecrets_SalesEvent_Model_Observer.php): failed
to open stream: No such file or directory in
/chroot/home/.../includes/src/Varien_Autoload.php on line 93
I've also verified that app/code/local is in my path. Also, I've debugged it down into App.php with Mage::log inserts.
Any help would be much appreciated as I am literally tearing my hair out.
Thanks
Dude you have the Magento compiler enabled, disable this from system > tools > compilation as compilation copies your files to include/src/ folder and all your changes are left unseen by magento after that (before you recompile at least)
Related
I am trying to write a script which has to execute when a module is updated. I wanted to check the version in db table core_resource, but i see now that the module is not added there. Am i looking in the wrong place, or is there something wrong with my code? This is the relevant part of the config file:
<?xml version="1.0"?>
<config>
<modules>
<mymodule>
<version>1.0.0.0</version>
</mymodule>
</modules>
<global>
<resources>
<update_myscript>
<setup>
<module>mymodule</module>
</setup>
</update_myscript>
</resources>
</global>
</config>
And i created an update file: /updateMyscript/upgrade-1.0.0.0-1.0.0.1.php
If your module has been registered on core_resource, you need to delete from that, for the setup execute again.
And if you want update the module setup, you need to create that upgrade file (upgrade-1.0.0.0-1.0.0.1.php) and alter the version on config.xml
Like this:
<mymodule>
<version>1.0.0.1</version>
</mymodule>
After this you need clear cache from Magento.
Sorry for my english.
Just a question. In my magento, when i refresh statistics in Reports / Resfresh statistics, it's okay but it redirects me on the homepage of my website.
I solved this problem by changing two lines code in app/code/core/Mage/adminhtml/controllers/Report/StatisticsController.php.
But it's better to create "an override".
So i decided to create a module in app/code/local/myname/.
I have my file in app/etc/modules myname_all.xml wich contains :
<?xml version="1.0"?>
<config>
<modules>
<MyName_AdminExtras>
<active>true</active>
<codePool>local</codePool>
</MyName_AdminExtras>
Next, I create app/code/local/Myname/AdminExtras/Adminhtml/etc/config.xml which contains
<?xml version="1.0"?>
<config>
<modules>
<MyName_AdminExtras>
<version>0.1.0</version>
</MyName_AdminExtras>
</modules>
<admin>
<routers>
<adminhtml>
<args>
<modules>
<MyName_AdminExtras before="Mage_Adminhtml">MyName_AdminExtras_Adminhtml</MyName_AdminExtras>
</modules>
</args>
</adminhtml>
</routers>
</admin>
And finally, i created a folder named controllers which contains another folder named Report and the file named StatisticsController.php which is calling the base file /app/code/core/Mage/Adminhtml/controllers/Report/StatisticController.php
But it doesn't word. File is not calling by Magento.
What's wrong ?
Hum sorry i found the answer. My folders weren't ok.
I just follow this way :
App/code/local/MyName/AdminExtras/controllers/adminhtml..
instead of
App/code/local/MyName/AdminExtras/Adminhtml/controllers
I have overridden the 'customer' frontname in order to make my custom module pages display as /customer/my-page-action/. When I do that my Helper class cannot be found:
Warning: include(Mage/FranchiseSelect/Helper/Data.php): failed to open stream: No such file or directory
Here's my extension config:
<?xml version="1.0" encoding="utf-8" ?>
<config>
<modules>
<Rhino_FranchiseSelect>
<active>true</active>
<codePool>local</codePool>
</Rhino_FranchiseSelect>
</modules>
</config>
Here's my module config:
<?xml version="1.0" encoding="utf-8" ?>
<config>
<modules>
<Rhino_FranchiseSelect>
<version>0.1.0</version>
</Rhino_FranchiseSelect>
</modules>
<frontend>
<routers>
<customer>
<args>
<modules>
<franchise before="Mage_Customer">Rhino_FranchiseSelect</franchise>
</modules>
</args>
</customer>
</routers>
<events>
<customer_session_init>
<observers>
<sessioninit_handler>
<type>singleton</type>
<class>Rhino_FranchiseSelect_Model_Observer</class>
<method>redirectToFranchise</method>
</sessioninit_handler>
</observers>
</customer_session_init>
<controller_action_predispatch_customer_account_create>
<observers>
<handler>
<type>singleton</type>
<class>Rhino_FranchiseSelect_Model_Observer</class>
<method>checkForRegion</method>
</handler>
</observers>
</controller_action_predispatch_customer_account_create>
</events>
</frontend>
<global>
<resources>
<helpers>
<what_should_this_tag_name_be>
<class>Rhino_FranchiseSelect_Helper</class>
</what_should_this_tag_name_be>
</helpers>
</resources>
</global>
</config>
My helper is located here:
/app/code/local/Rhino/FranchiseSelect/Helper/Data.php
I'm trying to instantiate it like so:
$helper = Mage::helper("what-should-this-path-be");
I'm not sure what the config helper alias tag name or helper path name should be in order to get this to work. Can you help me identify how this should be structured?
I'm not 100% sure it's the additional router configuration that's triggering this error — off the top of my head there's nothing in the controller dispatch process that instantiates a helper.
The most common reason for Magento to automatically instantiate a helper is a modules="helperalias" attribute in a configuration file. This indirectly invokes a helper's __ localization method.
Without knowing why your Magento system wants to instantiate a helper, it's impossible to know what the alias should be. If I was you I'd temporarily add something debugging code to the following file
#File: app/Mage.php
public static function helper($name)
{
//poor man's logging
file_put_contents('/tmp/test.log',"$name\n",FILE_APPEND);
// PHP's equivalent of printf debugging
var_dump($name);
$registryKey = '_helper/' . $name;
if (!self::registry($registryKey)) {
$helperClass = self::getConfig()->getHelperClassName($name);
self::register($registryKey, new $helperClass);
}
return self::registry($registryKey);
}
This will tell you what the helper's alias is, which is turn is what you should name the configuration node you're looking for.
Update: Based on the comment below, you want
<global>
<helpers>
<franchiseselect>
<class>Rhino_FranchiseSelect_Helper</class>
</franchiseselect>
</helpers>
</global>
When you say
Mage::helper('franchiseselect');
What you're really saying is
Mage::helper('franchiseselect/data');
Magento substitutes the data string automatically. The franchiseselect string is the alias group name, the data string is the alias model name. When you add the node <franchiseselect>/<what_should_this_tag_name_be/> always to your XML you're defining the alias group name.
Also, your XML had an extra node, <resources/>, under the <helpers/> node — you don't need that.
As for why the Magento looked for a class under Mage — if Magento can't find a configured alias, it automatically guesses that the request was for a class under the Mage namespace. This guess is a bit of paranoid programming on the part of the original core team to ensure any misconfigurations in their own modules didn't trigger errors. When Magento couldn't find your framework helper, it tried instantiating a Mage_Framework... class.
I would like to introduce my own entities into particular Magento module namespaces for example I might want to be able to call
Mage::getModel('catalog/brand')->load(1);
Brand is not currently a model included in the catalog module. I don't want to modify core files nor do I want to hack the core by just adding a Mage folder to the local directory.
I was thinking perhaps syntax inside of my namespaces config file similar to this:
<models>
<catalog>
<args>
<modules>
<AJW_Catalog before="Mage_Catalog">AJW_Catalog</AJW_Catalog>
</modules>
</args>
</catalog>
<ajw_catalog>
<class>AJW_Catalog_Model</class>
</ajw_catalog>
</models>
but it does not seem to work.
Does anyone know how this can be accomplished?
Maybe possible with some trickery, but not officially supported, and generally a bad idea. The before= syntax you've used only works for the routers node. There's no framework code to let you do what you're trying to do. Also, there's a strong bias in the Magento framework code towards individual modules "owning" their namespace/package name. Defining new models in an existing namespace (catalog) introduces the theoretical possibility that your code may conflicts with a future version of Magento's code.
This may be a possible fix (brain fart)
Create a module named Customnamespace_Catalog and then just rewrite the catalog module with a node that doesnt exist in the default mage module:
<?xml version="1.0"?>
<config>
<modules>
<Namespace_Catalog>
<version>0.1.0</version>
</Namespace_Catalog>
</modules>
<global>
<models>
<catalog>
<rewrite>
<brand>Namespace_Brand_Model_Brand</brand>
</rewrite>
</catalog>
</models>
</global>
</config>
Followed by an additional module:
<?xml version="1.0"?>
<config>
<modules>
<Namespace_Brand>
<version>0.1.0</version>
</Namespace_Brand>
</modules>
<global>
<models>
<brand>
<class>Namespace_Brand_Model</class>
</brand>
</models>
</global>
</config>
This will allow you to call Mage::getModel('catalog/brand')
echo get_class(Mage::getModel('catalog/brand'); // Namespace_Brand_Model_Brand
I'm stuck. Been messing with this all day. To me this looks like it should work but It's not, and its not outputting any errors to magento error log.
What I tried to do was simply override the getPriceHtml() function in Catalog/Block/Product.php. The module is active from the 'Advanced' tab via the system configuration.
My config.xml in app/code/local/Brian/Pricefix/etc/config.xml:
<config>
<modules>
<Brian_Pricefix>
<version>1.0</version>
</Brian_Pricefix>
</modules>
<global>
<blocks>
<catalog>
<rewrite>
<product>Brian_Pricefix_Catalog_Block_Product</product>
</rewrite>
</catalog>
</blocks>
</global>
</config>
My Brian_Pricefix.xml in app/etc/modules:
<config>
<modules>
<Brian_Pricefix>
<active>true</active>
<codePool>local</codePool>
</Brian_Pricefix>
</modules>
</config>
My Product.php in app/code/local/Brian/Pricefix/Catalog/Block/Product.php
class Brian_Pricefix_Catalog_Block_Product extends Mage_Catalog_Block_Product
{
public function getPriceHtml($product)
{
Mage::log("IM IN YOUR MODULEZ");
$this->setTemplate('catalog/product/price_fix.phtml');
$this->setProduct($product);
return $this->toHtml();
}
}
The new module isn't taking, its not logging anything or outputting price_fix.phtml
Any suggestions? I've done a few hours or research and this appears to be the right way to extend a block, so i'm not sure whats going on. The lack of error output is frustrating.
Thanks.
Looks like Mage_Catalog_Block_Product is not used anywhere.
catalog.xml contains mainly Mage_Catalog_Block_Product_View or Mage_Catalog_Block_Product_List calls.
You config looks fine. Try overriding another block.
Can you precise the page you are testing on?