I need to edit the below file
/var/www/magento1.9/app/code/core/Mage/Catalog/Model/Product/Attribute/Backend/Urlkey.php
i dont want to edit the core file
for which i have done this so far
<?xml version="1.0"?>
<config>
<modules>
<Inchoo_Coreextended>
<version>0.1.0</version>
</Inchoo_Coreextended>
</modules>
<global>
<models>
<catalog>
<rewrite>
<product>Inchoo_Coreextended_Model_Product_Attribute_Backend_Urlkey</product>
</rewrite>
</catalog>
</models>
</global>
</config>
i have created the folowing directory from where i like to extend the file
/var/www/magento1.9/app/code/local/Inchoo/Coreextended/Model/Product/Attribute/Backend/Urlkey.php
and file is as
class Inchoo_Coreextended_Model_Product_Attribute_Backend_Urlkey extends Mage_Catalog_Model_Attribute_Backend_Urlkey_Abstract
{
}
but when I am going to catalog pages i get following error
Fatal error: Call to undefined method Inchoo_Coreextended_Model_Product_Attribute_Backend_Urlkey::setStoreId() in /var/www/magento1.9/app/code/core/Mage/Adminhtml/controllers/Catalog/ProductController.php on line 66
please suggest where i am doing mistake
change your config.xml code
from
<global>
<models>
<catalog>
<rewrite>
<product>Inchoo_Coreextended_Model_Product_Attribute_Backend_Urlkey</product>
</rewrite>
</catalog>
</models>
</global>
to
<global>
<models>
<catalog>
<rewrite>
<product_attribute_backend_urlkey>Inchoo_Coreextended_Model_Product_Attribute_Backend_Urlkey</product_attribute_backend_urlkey>
</rewrite>
</catalog>
</models>
</global>
Related
grails version 3.3.1
cache-ehcache:3.0.0.M1
can somebody send me a valid ehcache.xmlplease?
My file looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="ehcache.xsd"
updateCheck="true"
monitoring="autodetect"
dynamicConfig="true">
<diskStore path="java.io.tmpdir"/>
<cache name="sevenSeconds"
maxEntriesLocalHeap="100"
maxEntriesLocalDisk="1000"
eternal="false"
timeToLiveSeconds="7"
timeToIdleSeconds="0"
memoryStoreEvictionPolicy="LFU"
transactionalMode="off">
<persistence strategy="localTempSwap" />
</cache>
<defaultCache
maxElementsInMemory="50000"
eternal="false"
timeToIdleSeconds="120"
timeToLiveSeconds="120"
overflowToDisk="true"
diskPersistent="false"
diskExpiryThreadIntervalSeconds="120"
memoryStoreEvictionPolicy="LRU"
/>
</ehcache>
and i get this error while startup:
Caused by: org.ehcache.xml.exceptions.XmlConfigurationException: Error parsing XML configuration at file:/home/user/workspaces/api2-grails/grails-app/conf/ehcacheCustom.xml
Caused by: org.xml.sax.SAXParseException: cvc-elt.1.a: Cannot find the declaration of element 'ehcache'.
thanks for suggestions
Since ehcache 3.0.0 the xml format changed. This is my base version:
<?xml version="1.0" encoding="UTF-8"?>
<config
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xmlns='http://www.ehcache.org/v3'
xsi:schemaLocation="ehcache-core.xsd">
<persistence directory="java.io.tmpdir"/>
<cache alias="twentySeconds">
<expiry>
<ttl unit="seconds">20</ttl>
</expiry>
<heap>2</heap>
</cache>
</config>
After struggling with the same issue I found this link and just took it as a base to get the following working example:
<ehcache:config xmlns:ehcache="http://www.ehcache.org/v3" xmlns:jcache="http://www.ehcache.org/v3/jsr107">
<ehcache:cache alias="books">
<ehcache:key-type>java.lang.String</ehcache:key-type>
<ehcache:value-type>hello.Book</ehcache:value-type>
<ehcache:resources>
<ehcache:heap unit="MB">1</ehcache:heap>
<!--ehcache:offheap unit="MB">10</ehcache:offheap-->
</ehcache:resources>
</ehcache:cache>
</ehcache:config>
My script runs perfect but dont save the new attribute in database.... why? thanks.
config.xml
<?xml version="1.0"?>
<config>
<modules>
<Itep_Incomm>
<version>0.1.0</version>
</Itep_Incomm>
</modules>
<global>
<models>
<incomm>
<class>Itep_Incomm_Model</class>
<resourceModel>incomm_mysql4</resourceModel>
</incomm>
</models>
<catalog>
<product>
<type>
<incomm_virtual translate="label" module="incomm">
<label>Incomm Virtual</label>
<model>incomm/product_virtual</model>
<price_model>incomm/product_price</price_model>
<is_qty>1</is_qty>
</incomm_virtual>
</type>
</product>
</catalog>
<resources>
<incomm_setup>
<setup>
<module>Itep_Incomm</module>
<class>Itep_Incomm_Model_Resource_Eav_Mysql4_Setup</class>
</setup>
<connection>
<use>core_setup</use>
</connection>
</incomm_setup>
<incomm_write>
<connection>
<use>core_write</use>
</connection>
</incomm_write>
<incomm_read>
<connection>
<use>core_read</use>
</connection>
</incomm_read>
</resources>
</global>
</config>
Script install in folder sql/incomm_setup/mysql4-install-0.1.0.php
<?php
$installer = $this;
$installer->startSetup();
//incomm_request_active_code att order
$installer->addAttribute('order_item','incomm_request_active_code',
array(
'type' => 'text',
'grid' => false
)
);
$installer->endSetup();
And the model/resource/eav/mysql4/setup.php
<?php
class Itep_Incomm_Model_Resource_Eav_Mysql4_Setup extends Mage_Sales_Model_Resource_Setup
{
}
When i run the script, and go to search in database, i cant find the new attribute in table Mage_Sales_Model_Resource_Setup, but the script shows in core_resouce, why my code is not saving? thanks
HI i have to extend the core controller in my own module for this i am referencing the below link
http://inchoo.net/tools-frameworks/how-to-extend-magento-core-controller/
below is my module structure
/var/www/magento1.9/app/etc/modules
<?xml version="1.0"?>
<!--we need to enable this module as any other if-->
<!--you wish to do it as standalone module extension-->
<config>
<modules>
<Inchoo_Coreextended>
<active>true</active>
<codepool>local</codepool>
</Inchoo_Coreextended>
</modules>
</config>
/var/www/magento1.9/app/code/local/Inchoo/Coreextended/controllers/Frontend/Customer/AccountController.php
<?php
require_once Mage::getModuleDir('controllers', 'Mage_Customer').DS.'AccountController.php';
//we need to add this one since Magento wont recognize it automatically
class Inchoo_Coreextended_Frontend_Customer_AccountController extends Mage_Customer_AccountController
{//here, you extended the core controller with our
public function indexAction()
{
parent::indexAction();
//you can always use default functionality
}
public function myactionAction()
{
//my code
//you can write your own methods / actions
}
public function mymethod()
{
//my code
//you can write your own methods
}
public function loginAction()
{
echo "hello";
//finally you can write your code that will rewrite the whole core method
//and you can call for your own methods, as you have full control over core controller
}
}
/var/www/magento1.9/app/code/local/Inchoo/Coreextended/etc/config.xml
<?xml version="1.0"?>
<config>
<modules>
<Inchoo_Coreextended>
<version>0.1.0</version>
</Inchoo_Coreextended>
</modules>
<frontend>
<routers>
<customer>
<args>
<modules>
<Inchoo_Coreextended before="Mage_Customer_AccountController">Inchoo_Coreextended_Frontend_Customer</Inchoo_Coreextended>
</modules>
</args>
</customer>
</routers>
</frontend>
</config>
but when i am accessing the http://localhost/magento1.9/index.php/customer/account/login/ it shows core login action and it is not switching from my module Can you please suggest where i am doing mistake .
I have fixed this by making changes in following file:
app/etc/modules/Inchoo_Coreextended.xml .
Before:
<config>
<modules>
<Inchoo_Coreextended>
<active>true</active>
<codepool>local</codepool>
</Inchoo_Coreextended>
</modules>
</config>
After:
<config>
<modules>
<Inchoo_Coreextended>
<active>true</active>
<codePool>local</codePool>
</Inchoo_Coreextended>
</modules>
</config>
codepool should be codePool
Hi i am developing a little magento module.
below is my directory structure of module
app/code/local/Xyz/Total
/var/www/magext/app/code/local/Xyz/Total/Block/Prototal.php
/var/www/magext/app/code/local/Xyz/Total/controllers/IndexController.php
/var/www/magext/app/code/local/Xyz/Total/etc/config.xml
/var/www/magext/app/code/local/Xyz/Total/Model/Price/Observer.php
below is my config file code
<?xml version="1.0"?>
<config>
<global>
<blocks>
<total>
<class>Xyz_Total_Block</class>
</total>
</blocks>
<models>
<xyztotal>
<class>Xyz_Total_Model</class>
</xyztotal>
</models>
<events>
<sales_order_place_after>
<observers>
<xyz_total_price_observer>
<type>singleton</type>
<class>Xyz_Total_Model_Price_Observer</class>
<method>apply_discount_percent</method>
</xyz_total_price_observer>
</observers>
</sales_order_place_after>
</events>
</global>
<frontend>
<routers>
<total>
<use>standard</use>
<args>
<module>Xyz_Total</module>
<frontName>newcatalog</frontName>
</args>
</total>
</routers>
<layout>
<updates>
<total>
<file>total.xml</file>
</total>
</updates>
</layout>
</frontend>
</config>
now what i need to install a product attribute through my module
.But i cant understand understand where should i put my installer
script and how to modify config file.
please suggest.
I saw your config.xml i am not able to find xml vesrion.
So you need to give xml version like below example:
<config>
<modules>
<Xyz_Total>
<version>0.1.0</version> <!-- Version of module -->
</Xyz_Total>
</modules>
</config>
Now create the file app/code/local/Xyz/Total/sql/total_setup/mysql4-install-0.1.0.php
After that reinstall the module And check it.
You also have to add below code in config.xml under config tag.
<global>
<resources> <!-- These are resource setting giving access to module, read/write permission on database -->
<total_setup>
<setup>
<module>Xyz_Total</module>
</setup>
<connection>
<use>core_setup</use>
</connection>
</total_setup>
<total_write>
<connection>
<use>core_write</use>
</connection>
</total_write>
<total_read>
<connection>
<use>core_read</use>
</connection>
</total_read>
</resources>
</global>
After that reinstall module.
Take a look # Adding custom product attributes in Magento using setup script
<modules>
<Xyz_Total>
<version>0.1.0</version>
</Xyz_Total>
</modules>
<global>
....
<models>
<xyztotal>
<class>Xyz_Total_Model</class>
<resourceModel>total_setup</resourceModel>
</xyztotal>
</models>
<resources>
<catalog_setup>
<setup>
<module>Mage_Catalog</module>
<class>Mage_Catalog_Model_Resource_Setup</class><!-- that line !-->
</setup>
</catalog_setup>
</resources>
...
In
app/code/local/Xyz/Total/sql/total_setup/mysql4-install-0.1.0.php
$installer->addAttribute('catalog_product', 'offer_type', array(
'backend' => '',
...
));
i am trying to implement an simple observer in my module (app/code/local/Foo/Bar).
My objective is to set the product names to '[product name] is cool' when a product is loaded in the frontend.
These are my files:
app/code/local/Foo/Bar/etc/config.xml
<?xml version="1.0" encoding="UTF-8"?>
<config>
<global>
<models>
<foo_bar>
<class>Foo_Bar_Model</class>
</foo_bar>
</models>
</global>
<frontend>
<events>
<catalog_product_load_after>
<observers>
<foo_bar>
<type>model</type>
<class>foo_bar/observer</class>
<method>catalogProductLoadAfter</method>
</foo_bar>
</observers>
</catalog_product_load_after>
</events>
</frontend>
</config>
app/code/local/Foo/Bar/Model/Observer.php
<?php
class Foo_Bar_Model_Observer{
public function catalogProductLoadAfter(Varien_Event_Observer $observer)
{
$product = $observer ->getProduct();
$product ->setName($product.getName().' '.'is cool');
}
}
?>
And i have also configured the module in app/etc/modules/Foo_Bar.xml
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<Foo_Bar>
<active>true</active>
<codePool>local</codePool>
</Foo_Bar>
</modules>
</config>
But it doenst work, does anyone have any suggestion?
You only need to module name for the model:
<foo_bar>
<type>model</type>
<class>bar/observer</class>
<method>catalogProductLoadAfter</method>
</foo_bar>
you don't need to specify Foo_Bar
also have you an error in your PHP
$product ->setName($product.getName().' '.'is cool');
should be
$product->setName($product->getName().' '.'is cool');