My own block class defined in community cood pool. But it not work with relevant template (Magento version 1.9 extension development) - magento-1.9

I try to create small extension for displaying string in Product page Magento 1.9.2. So I did it using "community" code pool for effecting block (block name ="product.info") in catalog.xml layout but it did not work till. I think my code is right but I don't sure whether all relevant folders (Controller, helper, Observer) are included or not in my module(Dinod). Please any one can help me to create this extension by using "community" code pool in Magento 1.9.2.
I failed to get expected output by testing my extension using "community" code pool. But same extension structure work fine after using "core" code pool. So I stored my module(Dinod) inside "app/code/core/Mage" folder and that time worked properly.
This code structure does not generate any expected output through frontend (product page).
app/etc/modules/Jpdn_Dinod.xml
<config>
<modules>
<Jpdn_Dinod>
<active>true</active>
<codePool>community</codePool>
</Jpdn_Dinod>
</modules>
</config>
app/code/community/Jpdn/Dinod/etc/config.xml
<config>
<modules>
<Jpdn_Dinod>
<version>1.0.3</version>
</Jpdn_Dinod>
</modules>
<frontend>
<layout>
<updates>
<Jpdn_Dinod module="Jpdn_Dinod">
<file>jpdn_dinod.xml</file>
</Jpdn_Dinod>
</updates>
</layout>
</frontend>
<global>
<!-- adding block "Jpdn_Dinod_Block_Product_View" -->
<blocks>
<jpdn_dinod>
<class>Jpdn_Dinod_Block_Product_View</class>
</jpdn_dinod>
</blocks>
<!-- adding block "Jpdn_Dinod_Block_Product_View" -->
</global>
</config>
app/code/community/Jpdn/Dinod/Block/Product/View/dinod.php
class Jpdn_Dinod_Block_Product_View_Dinod extends Mage_Core_Block_Template
{
public function dinod_methodblock()
{
$name = "Informations from dinod_methodblock in Jpdn_Dinod";
return $name;
}
}
app/design/frontend/base/default/layout/jpdn_dinod.xml
<layout version="1.0.3">
<catalog_product_view>
<reference name="product.info">
<!--
<block type="dinod/product_view_dinod" name="mage.view.dinod" as="mage.dinod" template="dinod/product/view/dinod.phtml">
<action method="addToParentGroup"><group>detailed_info</group></action>
<action method="setTitle" translate="value"><value>Dinodddd works</value></action>
</block>
-->
<block type="jpdn_dinod/product_view_dinod" name="jpdn.view.dinod" as="jpdn.dinod" template="dinod/product/view/dinod.phtml">
<action method="addToParentGroup"><group>detailed_info</group></action>
<action method="setTitle" translate="value"><value>Dinodddd works</value></action>
</block>
</reference>
</catalog_product_view>
</layout>
app/design/frontend/base/default/template/dinod/product/view/dinod.phtml
<?php echo $this->dinod_methodblock(); ?>
Above code structure does not generate any expected output through frontend (product page).
After I created new block class file in "app/code/core/Mage" and edited code in template file as below so I got expected output without any error.
app/code/core/Mage/Dinod/Block/Product/View/dinod.php
class Mage_Dinod_Block_Product_View_Dinod extends Mage_Core_Block_Template
{
public function dinod_methodblock()
{
$name = "Informations from dinod_methodblock in Mage_Dinod";
return $name;
}
}
app/design/frontend/base/default/layout/jpdn_dinod.xml
<layout version="1.0.3">
<catalog_product_view>
<reference name="product.info">
<block type="dinod/product_view_dinod" name="mage.view.dinod" as="mage.dinod" template="dinod/product/view/dinod.phtml">
<action method="addToParentGroup"><group>detailed_info</group></action>
<action method="setTitle" translate="value"><value>Dinodddd works</value></action>
</block>
<block type="jpdn_dinod/product_view_dinod" name="jpdn.view.dinod" as="jpdn.dinod" template="dinod/product/view/dinod.phtml">
<action method="addToParentGroup"><group>detailed_info</group></action>
<action method="setTitle" translate="value"><value>Dinodddd works</value></action>
</block>
</reference>
</catalog_product_view>
</layout>
But I want to get same output only using "community" code pool instead of using "core" code pool for effecting block (block name ="product.info") in catalog.xml layout.

Your block definition is wrong
<blocks>
<jpdn_dinod>
<class>Jpdn_Dinod_Block_Product_View</class>
</jpdn_dinod>
</blocks>
this is not how you should declare it. Remove product_view
<class>Jpdn_Dinod_Block</class>
this should be enough

Related

Magento 1.9.4 Third party model override doesn't work

I've been trying for days now to get a rewritten model to function. but it doesn't work, I'm puzzled because all seems to be correct.
___Here's my config file : etek/advancednewslettercoupon/etc/config.xml
<global>
<models>
<advancednewslettercoupon>
<class>Etek_AdvancedNewsletterCoupon_Model</class>
</advancednewslettercoupon>
<advancednewsletter>
<rewrite>
<subscriber>Etek_AdvancedNewsletterCoupon_Model_Subscriber</subscriber>
<rewrite>
</advancednewsletter>
</models>
</global>
__the subscriber model: Etek/AdvancedNewsletterCoupon/Model/Subscriber.php
class Etek_AdvancedNewsletterCoupon_Model_Subscriber extends AW_Advancednewsletter_Model_Subscriber
{
_construct() {
var_dump('Etek Subscriber');die(get_class($this));
}
public function subscribe($email, $segments, $params = array())
{ echo"<pre>";die('Etek Subscriber');
}
___Etek_AdvancedNewsletterCoupon.xml
<?xml version="1.0"?>
<config>
<modules>
<Etek_AdvancedNewsletterCoupon>
<active>true</active>
<codePool>local</codePool>
<depends>
<AW_Advancednewsletter/>
</depends>
</Etek_AdvancedNewsletterCoupon>
</modules>
</config>
I found out that I forgot to close the tag of rewrite:
<rewrite>
<subscriber>Etek_AdvancedNewsletterCoupon_Model_Subscriber</subscriber>
</rewrite>
Now all seems to work fine :)

Biml Master-Child package connections

In a 2008 BIDS/SQL Server/SSIS dev environment (along with BIDS Helper v1.70), I'm trying to create a biml master package that executes the child packages already built under Rootnode. Also using a config file to be able to run the entire process on different servers.
Config File
?xml version="1.0"?>
<DTSConfiguration>
<DTSConfigurationHeading><DTSConfigurationFileInfo GeneratedBy="XXXXXX" GeneratedDate="7/28/2016 1:28:29 PM"/></DTSConfigurationHeading>
<Configuration ConfiguredType="Property" Path="\Package.Connections[dw].Properties[ConnectionString]" ValueType="String">
<ConfiguredValue>Data Source=imsqldv50s\euc;Initial Catalog=CDODW;Provider=SQLNCLI10.1;Integrated Security=SSPI;</ConfiguredValue>
</Configuration>
<Configuration ConfiguredType="Property" Path="\Package.Connections[PkgFile].Properties[ConnectionString]" ValueType="String">
<ConfiguredValue>\\IMSQLDV50s\EUCPACKAGES\CDODW\Load CDODW Tables Biml\</ConfiguredValue>
</Configuration>
<Configuration ConfiguredType="Property" Path="\Package.Variables[User::ChildPackagePath].Properties[Value]" ValueType="String">
<ConfiguredValue>\\IMSQLDV50s\EUCPACKAGES\CDODW\Load CDODW Tables Biml\</ConfiguredValue>
</Configuration>
</DTSConfiguration>
The building of the child packages has been tested and passed. Now we are attempting to build the Master Package.
05-load-edw-master.biml
<Biml xmlns="http://schemas.varigence.com/biml.xsd">
<Packages>
<Package Name ="Master EDW Load" ConstraintMode ="Linear">
<PackageConfigurations>
<PackageConfiguration Name="dw">
<ExternalFileInput ExternalFilePath="C:\SSISConfig\CDODW_ETL_Load.dtsConfig" />
<ConfigurationValues>
<ConfigurationValue DataType="String" Name="dw" PropertyPath="\Package.Connections[dw].Properties[ConnectionString]" Value=""></ConfigurationValue>
</ConfigurationValues>
</PackageConfiguration>
<PackageConfiguration Name="PkgFile">
<ExternalFileInput ExternalFilePath="C:\SSISConfig\CDODW_ETL_Load.dtsConfig" />
<ConfigurationValues>
<ConfigurationValue DataType="String" Name="PkgFile" PropertyPath="\Package.Connections[PkgFile].Properties[ConnectionString]" Value=""></ConfigurationValue>
</ConfigurationValues>
</PackageConfiguration>
</PackageConfigurations>
<#=CallBimlScript("cbs-pkg-params-variables.biml", "No Table", "master-load", "","","")#>
<!--
<Connections>
<Connection ConnectionName="dw" />
<Connection ConnectionName="PkgFile">
<Expressions>
<Expression PropertyName="PkgFile.ConnectionString">#[User::ChildPackagePath]</Expression>
</Expressions>
</Connection>
</Connections>
-->
<Tasks>
<#=CallBimlScript("cbs-sql-audit-begin.biml", "master-load")#>
<Container Name="SEQ Load Dimensions" ConstraintMode="Linear">
<Tasks>
<# foreach (var package in RootNode.Packages.Where(pkg => pkg.GetTag("type")=="load-edw-dim").OrderBy(pkg => pkg.GetTag("LoadOrder"))) { #>
<ExecutePackage Name="EP <#=package.Name#>" DelayValidation="true">
<Package PackageName="<#=package.Name #>" />
</ExecutePackage>
<# } #>
</Tasks>
</Container>
<Container Name="SEQ Load Facts" ConstraintMode="Linear">
<Tasks>
<# foreach (var package in RootNode.Packages.Where(pkg => pkg.GetTag("type")=="load-edw-fact").OrderBy(pkg => pkg.GetTag("LoadOrder"))) { #>
<ExecutePackage Name="EP <#=package.Name #>" DelayValidation="true">
<Package PackageName="<#=package.Name #>" />
</ExecutePackage>
<# } #>
</Tasks>
</Container>
<#=CallBimlScript("cbs-sql-audit-end.biml")#>
</Tasks>
<Annotations>
<Annotation AnnotationType="Tag" Tag="type">master-load</Annotation>
</Annotations>
</Package>
</Packages>
</Biml>
<## template language="C#" tier="5"#>
The Connections have already been defined in a tier 1 file
After generating the packages, I note that the Biml engine creates Connection Managers using a convention "_" + Master Package Name.SequenceContainerName.ExecutePackageName, with a connection string pointing to the local file path. And it's doing so "under the covers" as there is no clue in the expanded biml file of how it's done!
Is there a nice simple way to interject a passed-in file path from the config file that can be recognized and used to build each FileConnection's data? I thought it would make sense to store the relevant file location in a variable (fed from the config file) and somehow use that to develop the ConnectionString from the package name garnered from the foreach snippet, but the engine doesn't appear to like that.
Any help is appreciated.
Thanks!

Magento add limit to product collection

I'm trying to show last 150 added products.
I'm creating the module and add in xml
<reference name="content">
<!-- Add product list to content -->
<block type="newprod/product_list" name="product_list" template="catalog/product/list.phtml">
<!-- Add toolbar to product list -->
<block type="catalog/product_list_toolbar" name="product_list_toolbar" template="catalog/product/list/toolbar.phtml">
<!-- Add pager to toolbar -->
<block type="page/html_pager" name="product_list_toolbar_pager"/>
</block>
<!-- Specify toolbar block name -->
<action method="setToolbarBlockName">
<name>product_list_toolbar</name>
</action>
<!-- Use custom product collection -->
<action method="setCollection">
<value helper="newprod/getProductCollection" />
</action>
<!-- Use custom available sort by orders -->
<action method="setAvailableOrders">
<value helper="newprod/getAvailableOrders" />
</action>
<!-- Set the default sort by order -->
<action method="setSortBy">
<value>price</value>
</action>
<!-- Set default direction to ascending -->
<action method="setDefaultDirection">
<value>asc</value>
</action>
<action method="setColumnCount">
<column>12</column>
</action>
<action method="setLimit"><limit>50</limit></action>
</block>
</reference>
in getProductCollection
public function getProductCollection()
{
$collection = Mage::getResourceModel('reports/product_collection')
->addStoreFilter($store_id)
->addAttributeToFilter('visibility', 4)
->addAttributeToFilter('status', 1)
->addAttributeToSelect('*')
->setVisibility(array(2,3,4))
->setOrder('created_at', 'desc')
->setPage(1, 9);
return $collection;
}
but in result page I get n items on page and it's fine, but pager render for all 10000 products, how can I limit this? I'm trying to play with _beforeToHtml() function from mycomp_NewProd_Block_Product_List extends Mage_Catalog_Block_Product_List but now luck.
Maybe you can add
->setPageSize(150)
before return collection.

Parent package is not defined : jfreechart-default [Unknown Location]

I am trying use Struts2 jfreechart plugin - using a Maven project.
In Maven dependencies I am able to see the jfree-chart jar file.
DO I need to use a separate package?
Getting following error:
SEVERE: Dispatcher initialization failed
Unable to load configuration. - [unknown location]
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:70)
at org.apache.struts2.dispatcher.Dispatcher.getContainer(Dispatcher.java:967)
at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:435)
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:479)
at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:74)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:57)
at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:279)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:260)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:105)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4828)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5508)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1575)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1565)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Caused by: Parent package is not defined: jfreechart-default - [unknown location]
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.buildPackageContext(XmlConfigurationProvider.java:674)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addPackage(XmlConfigurationProvider.java:523)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadPackages(XmlConfigurationProvider.java:295)
at org.apache.struts2.config.StrutsXmlConfigurationProvider.loadPackages(StrutsXmlConfigurationProvider.java:112)
at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:264)
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:67)
... 17 more
My struts.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<constant name="struts.devMode" value="true"></constant>
<package name="basicstruts2" extends="struts-default, jfreechart-default">
<action name="index">
<result>/index.jsp</result>
</action>
<action name="getchart" class="com.struts.charts.actions.ChartAction"
method="execute">
<result name="success" type="chart">
<param name="width">400</param>
<param name="height">300</param>
</result>
</action>
</package>
</struts>
In the struts.xml you have used the code that requires struts2-jfreechart-plugin-x.x.x.jar to be on classpath. This plugin has struts-plugin.xml where the jfreechart-default package is defined. You need this if your package extends jfreechart-default.
<package name="basicstruts2" extends="struts-default, jfreechart-default">

can't set Struts2 result type to json

I want to use json with Struts2. However, when I set the action return type to "json", I got "there is no result type defined for type 'json' mapped with name 'success'." Bellow is struts.xml file.
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<constant name="struts.custom.i18n.resources" value="resource"/>
<package extends="struts-default" name="test">
<action name="inputHandler" class="inputHandlerAction">
<result name="input">/index.jsp</result>
<result>/result.jsp</result>
</action>
<action name="setLangHandler" class="com.sesoft.test.setLanguageHandler">
<result>/index.jsp</result>
</action>
<action name="Handler" class="com.sesoft.test.Handler">
<result>/test2.jsp</result>
</action>
</package>
<package name="example" extends="json-default">
<action name="ajaxHandler" class="com.sesoft.test.AjaxHandler">
<result name="success" type="json" />
</action>
</package>
</struts>
Before I added the json Action, all other action performs fine. But after I added the json Action, the server failed to action with error code 503.
libs I've added "jsonplugin-0.33.jar" to the lib directory.
You don't have the JSON result defined in your struts.xml package. If you only need default things then you can just extend json-default instead of struts-default. If you need to customise the package then include the following and that should do the trick:
<result-types>
<result-type name="json" class="com.googlecode.jsonplugin.JSONResult"/>
</result-types>
you package should extends json-default
<package name="json-default" extends="struts-default">
<result-types>
<result-type name="json" class="org.apache.struts2.json.JSONResult"/>
</result-types>
<interceptors>
<interceptor name="json" class="org.apache.struts2.json.JSONInterceptor"/>
</interceptors>
</package>
If using Maven you may need to add the dependency e.g.
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-json-plugin</artifactId>
<version>2.2.3</version>
</dependency>
Here is my configuration in pom.xml:
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
<version>2.3.1.2</version>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-json-plugin</artifactId>
<version>2.3.1.2</version>
</dependency>
In the action result you only need to specify type="json" :
<result type="json"/>
Remember the variable getter and setter in type="json" response give getters in the action.
Include json-default in the extends parameter:
<package name="default" extends="struts-default,json-default">
<action>
...
...
</action>
</package>