I am trying to add a new attribute to tier pricing and when i try to override the tierprice class i get "Invalid backend model specified: catalog/product_attribute_backend_tierprice" error when i try to save an item and in frontend I cant view any item.
please help me.
In my config.xml i have defined the classes as
<modules>
<Mypackage_Catalog>
<version>0.1.0</version>
</Mypackage_Catalog>
</modules>
<global>
<models>
<catalog>
<rewrite>
<product_type_price>Mypackage_Catalog_Model_Product_Type_Price</product_type_price>
<product_attribute_backend_tierprice>Mypackage_Catalog_Model_Product_Attribute_Backend_Tierprice</product_attribute_backend_tierprice>
</rewrite>
</catalog>
<catalog_resource_eav_mysql4>
<rewrite>
<product_attribute_backend_tierprice>Mypackage_Catalog_Model_Resource_Eav_Mysql4_Product_Attribute_Backend_Tierprice</product_attribute_backend_tierprice>
</rewrite>
</catalog_resource_eav_mysql4>
</models>
</global>
and my folder structure looks like
app\code\local\Mypackage\Catalog\Model\Resource\Eav\Mysql4\Product\Attribute\Backend\Tierprice.php
For me it seems you overwrite 3 classes in your config xml, but there is only one exists in your folder structure. I tried the module as you describe it here (but no modifications to core files, just copied them and changed class definitions) and get the same error. In the system.log this error looks like:
Failed opening 'Mypackage\Catalog\Model\Product\Attribute\Backend\Tierprice.php' for inclusion
In your folder structure you will need the following files (in addition to existing one):
app\code\local\Mypackage\Catalog\Model\Product\Attribute\Backend\Tierprice.php
app\code\local\Mypackage\Catalog\Model\Product\Type\Price.php
From what I see, your file tierprice.php should be capitalized, and if that doesn't do it, post your Tierprice.php file
Related
I have one project for publishing two separate websites on different servers. Both websites is in different languages (En and tr).
For web-deploy I want to change appsettings for different environments for Debug and Release (For both websites).
I added config files for transformations like this:
Appsetting in main Web.config:
<add key="WebsiteMainCulture" value="en-US"/>
The code in transformation files are accordingly like this:
<appSettings>
<add key="WebsiteMainCulture" value="TR"
xdt:Locator="Match(key)" xdt:Transform="Replace"/>
</appSettings>
I selected Web.TR.Debug.config and ran project, But I always get 'en-US' as WebsiteMainCulture.
string website_main_culture = ConfigurationManager.AppSettings["WebsiteMainCulture"].ToString(); // always en-US
Please help. Is there any better approach suggested for same environment?
Thanks!
I got the solution for the problems I asked, also related to my previous question here:
https://stackoverflow.com/questions/30612865/selecting-correct-seed-method-for-particular-language
I just added config transformation files by right clicking, to relevant publish(web deploy) files.Then added desired values to keys. And it worked.
Here are config transformation file auto generated.
I am using JSR 303 Bean validation in my JSF 2.0 web application and it works fine with annotations. Now I would like to ignore annotations and configure validation rules using the validation.xml file, so this is what I did (I am using an eclipse dynamic web project) :
Added validation.xml under WebContent/META-INF/validation.xml
<?xml version="1.0" encoding="UTF-8"?>
<validation-config
xmlns="http://jboss.org/xml/ns/javax/validation/configuration"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://jboss.org/xml/ns/javax/validation/configuration validation-configuration-1.0.xsd"
>
<constraint-mapping>META-INF/validation/constraint-mapping.xml</constraint-mapping>
</validation-config>
Then created the file constraint-mapping.xml under WebContent/META-INF/validation/constraint-mapping.xml
<constraint-mappings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://jboss.org/xml/ns/javax/validation/mapping validation-mapping-1.0.xsd"
xmlns="http://jboss.org/xml/ns/javax/validation/mapping">
<bean class="my.full.path.ValidationMB" ignore-annotations="true">
</bean>
</constraint-mappings>
Having these configurations in place, I suppose the annotations in my bean class ValidationMB shall be ignored, BUT this is not happening!, which makes me assume that the validation.xml file is not being loaded.
any ideas? thanks.
Environment:
Apache Tomcat 7.0.23
javax.faces-2.1.4.jar
hibernate-validator-4.2.0.Final.jar
hibernate-validator-annotation-processor-4.2.0.Final.jar
validation-api-1.0.0.GA.jar
slf4j-api-1.6.1.jar
From the spec: section 4.4.6. XML Configuration: META-INF/validation.xml
Unless explicitly ignored by calling
Configuration.ignoreXMLConfiguration(), a Configuration takes into
account the configuration available in META-INF/validation.xml. This
configuration file is optional but can be used by applications to
refine some of the Bean Validation behavior. If more than one
META-INF/validation.xml file is found in the classpath, a
ValidationException is raised.
To solve my problem I had to create a META-INF folder under the project src folder, which ends in the WEB-INF/classes/META-INF.
The structure of the web application is:
ROOT
|_META-INF -- don't put validation.xml here
|_WEB-INF
|__ classes
|_META-INF
|__validation.xml
But I think that if I pack my web application in a jar file and reuse it in another project It may not work, I will let you know later once I do it.
Try to put your validation.xml directly into the WEB-INF/ directory.
I stumbled across this while looking for something else but wanted to clarify to the OP what is happening. You do in fact need the file to exist at META-INF/validation.xml; however, that is relative to the classpath which is why it worked when you put it under WEB-INF/classes/META-INF/validation.xml.
The cleaner approach is to let the file be put there for you. Your Eclipse project should already be outputting whatever is in your source directory to WEB-INF/classes somehow for you or nothing would be running. But sometimes there are filters on what it outputs so it might excluding something. You might want to check your src dirs and make sure they don't have exclusions.
Just as an example, if you had a Maven war project, all of your java sources would go in src/main/java and the generated classes would end up in the WEB-INF/classes directory. The equivalent happens for src/main/resources which contains non-source files. When I want *.xml, *.properties, etc. to end up in WEB-INF/classes I put them in src/main/resources. For your example I would have a src/main/resources/META-INF/validation.xml file.
Hope this helps anyone else who comes across this and is confused.
my site uses JSF and the url appears to be, http://mysitename.com/wompower6/faces/home.xhtml
I am using prettyfaces, so if I use the following in pretty-config.xml, i can change the name to http://mysitename.com/wompower6/home
<url-mapping id="home">
<pattern value="/home" />
<view-id value="/faces/home.xhtml" />
</url-mapping>
my questions are
how can i remove the application
name wompower6 , so that the url
becomes mysitename.com/home ?
in my web.xml, i have
<welcome-file>home.xhtml</welcome-file>,
but this does not seem to work. When
i type, mysitename.com, it does not
get mapped to home.xhtml. any clue
here?
how can i remove the application name wompower6 , so that the url becomes mysitename.com/home?
This is a webapp <Context> setting and configuration is dependent on the servletcontainer used. If you're for example using Tomcat, then there are basically 2 options to make your webapp the root webapp.
Rename the WAR file to ROOT.war and Tomcat will by default deploy it on context root.
Set path attribute of <Context> element in Webapp/META-INF/context.xml (or Tomcat/conf/server.xml, depending where you'd like to define it) to an empty String. E.g.
<Context path="" ...>
Other containers support similar constructs. Consult their documentation for detail. If you're using an IDE like Eclipse, then you can also set it in the Web Project Settings property of the project properties (rightclick project and choose Properties). Set the Context root value to just /.
in my web.xml, i have home.xhtml, but this does not seem to work. When i type, mysitename.com, it does not get mapped to home.xhtml. any clue here?
I assume that you're talking about the <welcome-file> setting. This has to point to a physically existing file, not to a virtual URL, such as /faces/*. There are basically two ways to overcome this:
Provide a physically existing /faces/home.xhtml file (it can even be left empty).
Replace the ugly /faces/* URL pattern of the FacesServlet mapping in web.xml by *.xhtml so that it will just kick in on every request for a XHTML file.
<url-pattern>*.xhtml</url-pattern>
This way you don't need to fiddle with /faces/* URL patterns.
When I try to build my project, I get the following error:
error : Unable to update the AssemblyFileVersion for c:\builddir\MyProject\AssemblyInfo.cs: No stub entry for AssemblyFileVersion was found in the AssemblyInfo file.
I found this article, which implies that a "stub" property is required. So, in my AssemblyInfo.cs, I tried to specify one:
[assembly: AssemblyFileVersion("1.0.0")]
However, it isn't recognised. I finally came across this article, which says that you can't use the AssemblyFileVersion property with the CF. The targets file used by the build script is also used for building other, non CF projects, and needs to update the FileVersion for them.
Is it possible to put something in the AssemblyInfo.cs file, the target file or the build script that stops this from being an issue?
Yes, something like this:
#if !(WindowsCE || PocketPC)
[assembly: AssemblyFileVersion("1.0.0")]
#endif
If using the preprocessor in the manner described in the other answer doesn't work for you, consider putting the AssemblyFileVersion attribute into a separate source file, and conditionally including that source file in the project:
<Compile Include="AssemblyInfo.cs" />
<Compile Include="AssemblyInfo.AssemblyVersion.cs"
Condition="
'$(TargetPlatform)' == 'WindowsCE' OR
'$(TargetPlatform)' == 'PocketPC'"
/>
I'm not sure if there is already a property you can use in the project file, or if you would need to declare your own (perhaps $(Platform) is used for this?)
I'm trying to use xmltask for ant to modify a file in a subdirectory:
project/path/to/file.xml
The file refers to a DTD like this:
<!DOCTYPE data SYSTEM "mydtd.dtd">
I don't have the flexibility to change these documents.
This DTD is stored in the same subdirectory, which has always worked fine:
project/path/to/mydtd.dtd
Unfortunately, xmltask is trying to locate the dtd in my project's top-level directory, which is where my build file is located, and where I run from:
[xmltask] java.io.FileNotFoundException: /home/me/project/mydtd.dtd (The system cannot find the file specified)
I see in the xmltask documentation that I can correct this with an xmlcatalog element to tell it where to look up the file. But I need to use a dtd element, and I can only find examples for this element, not documentation; the examples show only a publicId, and if I understand XML correctly this document does not have one. I shouldn't need to specify this, anyway, right, since my document already says my DTD is stored locally and shows right where it is?
Why isn't xmltask finding the DTD correctly? What's the best way to correct or work around this situation?
An XML Catalog is the way to go here, it just needs a bit more perseverance.
As you correctly pointed out, the standard Ant <XmlCatalog> type only allows you to specify public DTD references when using the inline syntax, which is of no use to you. However, <XmlCatalog> also lets you specify a standard OASIS-syntax catalog, which is far richer, including resolving SYSTEM DTD references.
An OASIS catalog (full spec here) looks like this:
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
<system systemId="mydtd.dtd" uri="project/path/to/mydtd.dtd"/>
</catalog>
You can then reference this catalog from the <XmlCatalog>:
<xmlcatalog refid="commonDTDs"/>
<catalogpath>
<pathelement location="path/to/oasis.catalog"/>
</catalogpath>
</xmlcatalog>
And that's that. It's a good idea to build up a reusable OASIS catalog file, and refer to it from various XML-related Ant tasks, all of which can use <XmlCatalog>.
As an alternative, it looks like I can skip the whole validation by creating a blank file with the same name as the DVD file, and then deleting the file when I am done. Odds are I am going to go that route instead of using the catalog.
xmltask isn't finding it because it is looking in the current working directory. Ant allows you to specify a base directory using the basedir attribute of the <target> element. So I suggest you try this:
<target basedir="path/to" ...>
<xmltask...
</target>
It strikes me that it is not the XML/DTD that you really have the problem with, but getting xmltask to interact with the two of them as you want.
If that fails, you could use the Ant Copy task to copy the XML and DTD to the root folder before processing with xmltask, then copying back again.
Have you tried:
<!DOCTYPE data SYSTEM "./path/to/mydtd.dtd">
? Or an absolute path?
Also, you can find <dtd> description here.
I had a similar problem where an XML file had a doctype with SYSTEM reference that could not be changed.
<!DOCTYPE opencms SYSTEM "http://www.opencms.org/dtd/6.0/opencms-modules.dtd">
I first went down the road and created a catalog file with the OASIS catalog as described above, but to be able to use external catalogs I had to include the Apache Commons Resolver 1.1 (resolver.jar) in the Ant classpath (see http://ant.apache.org/manual/Types/xmlcatalog.html).
Because I had multiple machines on which this build was supposed to run this seemed overkill, especially since xmltask worked fine if I just removed the doctype definition. I wasn't allowed to remove it permanently because the doctype was needed elsewhere.
Ultimately I used this workaround: I commented out the doctype definition using Ant's replace task, ran the xmltask, and then put the doctype back into the file.
<replace file="myxmlfile.xml">
<replacetoken><!DOCTYPE opencms SYSTEM "http://www.opencms.org/dtd/6.0/opencms-modules.dtd"></replacetoken>
<replacevalue><!-- !DOCTYPE opencms SYSTEM "http://www.opencms.org/dtd/6.0/opencms-modules.dtd" --></replacevalue>
</replace>
<xmltask .../>
<replace file="${local.opencms.webapp.webinf}/config/opencms-modules.xml">
<replacetoken><!-- !DOCTYPE opencms SYSTEM "http://www.opencms.org/dtd/6.0/opencms-modules.dtd" --></replacetoken>
<replacevalue><!DOCTYPE opencms SYSTEM "http://www.opencms.org/dtd/6.0/opencms-modules.dtd"></replacevalue>
</replace>