Color swatch on compare page in magento2 - magento2

Magento2
How can be get the color swatch on product compare page..

To have color swtach on product compare page you need to create custom module:-
Create a layout file with the name as catalog_product_compare_index.xml and add below code in the file created.
<?xml version="1.0"?>
<page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<head>
<css src="Magento_Swatches::css/swatches.css"/>
</head>
<body>
<referenceContainer name="content">
<referenceBlock name="catalog.compare.list">
<action method="setTemplate">
<argument name="template" xsi:type="string">W3solver_Compareswatch::product/compare/list.phtml</argument>
</action>
<block class="Magento\Framework\View\Element\RendererList" name="category.product.type.details.renderers" as="details.renderers">
<block class="Magento\Swatches\Block\Product\Renderer\Listing\Configurable" as="configurable" template="Magento_Swatches::product/listing/renderer.phtml" />
</block>
</referenceBlock>
</referenceContainer>
</body>
</page>
You need to add one function in your overriden list.phtml on line 63
<?php
if($_item->getTypeId() == "configurable"):
echo $block->getProductDetailsHtml($_item);
endif;
?>
This will show the color patches on compare page.

Related

Moving Coupon Block on the top of the page

I would like to move coupon block on the upper side of the page (before cart summary).
Coupon block are located on: App/design/frontend/mytheme/themename/default/Magento_Checkout/layout/checkout_cart_index.xml
<page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="checkout.cart.container">
<container name="cart.discount" label="Cart Discount Container" htmlTag="div" htmlClass="cart-discount" after="-" />
</referenceContainer>
<move element="checkout.cart.crosssell" destination="checkout.cart.container" after="-" />
<move element="checkout.cart.coupon" destination="cart.discount" />
<move element="checkout.cart.shortcut.buttons" destination="checkout.cart.methods" after="checkout.cart.methods.onepage.bottom"/>
</body>

How to display shipping country in sales order grid in magento 2

I tried to show the shipping country in the Admin Sales Order Grid but nothing works.
I did check the customer address configuration twice and there I can see that the country variable exists and should be shown. But in the grid you can not see the shipping country.
Any workarounds?
I found a solution. Creating a Module and Rewrite Class.
app/code/Vendor/ExtendedAdminGrid/etc/di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory">
<arguments>
<argument name="collections" xsi:type="array">
<item name="sales_order_grid_data_source" xsi:type="string">Vendor\ExtendedAdminGrid\Model\ResourceModel\Order\Grid\Collection</item>
</argument>
</arguments>
</type>
</config>
app/code/Vendor/ExtendedAdminGrid/etc/module.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Vendor_ExtendedAdminGrid" setup_version="2.0.0">
<sequence>
<module name="Magento_Sales"/>
<module name="Magento_Backend"/>
</sequence>
</module>
</config>
app/code/Vendor/ExtendedAdminGrid/Model/ResourceModel/Order/Grid/Collection.php
<?php
namespace Vendor\ExtendedAdminGrid\Model\ResourceModel\Order\Grid;
class Collection extends \Magento\Sales\Model\ResourceModel\Order\Grid\Collection
{
protected function _renderFiltersBefore()
{
$this->getSelect()->joinLeft(
["soa" => "sales_order_address"],
"main_table.entity_id = soa.parent_id and soa.address_type = 'shipping'",
array('country_id')
)
->distinct();
parent::_renderFiltersBefore();
}
protected function _initSelect()
{
$this->addFilterToMap('created_at', 'main_table.created_at');
$this->addFilterToMap('base_grand_total', 'main_table.base_grand_total');
$this->addFilterToMap('grand_total', 'main_table.grand_total');
$this->addFilterToMap('store_id', 'main_table.store_id');
$this->addFilterToMap('store_name', 'main_table.store_name');
$this->addFilterToMap('order_id', 'main_table.order_id');
$this->addFilterToMap('order_increment_id', 'main_table.order_increment_id');
$this->addFilterToMap('billing_name', 'main_table.billing_name');
$this->addFilterToMap('billing_name', 'main_table.shipping_name');
$this->addFilterToMap('status', 'main_table.status');
parent::_initSelect();
}
}
app/code/Vendor/ExtendedAdminGrid/view/adminhtml/ui_component/sales_order_grid.xml
<?xml version="1.0" encoding="UTF-8"?>
<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
<columns name="sales_order_columns">
<column name="country_id">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">text</item>
<item name="label" xsi:type="string" translate="true">Shipping Country ID</item>
</item>
</argument>
</column>
</columns>
</listing>
app/code/Vendor/ExtendedAdminGrid/registration.php
<?php
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::MODULE,
'Vendor_ExtendedAdminGrid',
__DIR__
);
Thanks to Sergey for this great blogpost Modifying the default magento2 sales order grid — adding a coupon code column.

Magento 2 Block not adding

Magento 2 related Problem:
The header.phtml gets included but the purchase.phtml doesn't and we can't find the issue why. This bug only appears on our success page
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceBlock name="head.additional">
<block class="Anowave\Ec\Block\Track" name="ec_header" as="ec_header" template="header.phtml" />
<block class="Anowave\Ec\Block\Track" name="ec_purchase" as="ec_purchase" template="purchase.phtml" >
<block class="Anowave\Ec\Block\Track" name="ec_datalayer" as="ec_datalayer" template="datalayer.phtml" />
<block class="Anowave\Ec\Block\Track" name="ec_impressions" as="ec_impressions" template="impression.phtml" />
<block class="Anowave\Ec\Block\Track" name="ec_search" as="ec_search" template="search.phtml" />
<block class="Anowave\Ec\Block\Track" name="ec_detail" as="ec_detail" template="detail.phtml" />
</block>
</referenceBlock>
<referenceContainer name="after.body.start">
<block class="Anowave\Ec\Block\Track" name="ec_noscript" as="ec_noscript" template="noscript.phtml" />
</referenceContainer>
<referenceContainer name="before.body.end">
<block class="Anowave\Ec\Block\Track" name="ec_events" as="ec_events" template="events.phtml" />
<block class="Anowave\Ec\Block\Track" name="ec_promotions" as="ec_promotions" template="promotions.phtml" />
<block class="Anowave\Ec\Block\Track" name="ec_footer" as="ec_footer" template="footer.phtml" />
</referenceContainer>
</body>
</page>
Looks like you want call templates in a template. Try insert the code below in your purchase.phtml:
include ($block->getTemplateFile('Anowave_ec::search.phtml'));

Oracle ADF Essentials 10.2.1 Task Flow Not Working

I have create a simple JSPX file and a Task Flow using Eclipse Neon OEPE 12.2.1.5
Task Flow XML mainTab.xml
<?xml version="1.0" encoding="UTF-8"?>
<adfc-config xmlns="http://xmlns.oracle.com/adf/controller" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.oracle.com/adf/controller http://xmlns.oracle.com/adf/controller/adfc-config_1_0.xsd">
<task-flow-definition id="mainTab">
<default-activity>view1</default-activity>
<view id="view1">
<page>/view1.jsff</page>
</view>
<view id="view2">
<page>/view2.jsff</page>
</view>
<control-flow-rule>
<from-activity-id>view1</from-activity-id>
<control-flow-case>
<from-outcome>openView2</from-outcome>
<to-activity-id>view2</to-activity-id>
</control-flow-case>
</control-flow-rule>
<control-flow-rule>
<from-activity-id>view2</from-activity-id>
<control-flow-case>
<from-outcome>openView1</from-outcome>
<to-activity-id>view1</to-activity-id>
</control-flow-case>
</control-flow-rule>
<use-page-fragments/>
</task-flow-definition>
</adfc-config>
Main JSPX file
<?xml version='1.0' encoding='UTF-8'?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
<jsp:directive.page contentType="text/html;charset=UTF-8" />
<f:view>
<af:document id="d1">
<af:form id="f1">
<af:panelStretchLayout id="psl1">
<f:facet name="center">
<af:region value="#{bindings.mainTab.regionModel}"
id="r1" />
</f:facet>
</af:panelStretchLayout>
</af:form>
</af:document>
</f:view>
</jsp:root>
First View view1.jsff
<?xml version='1.0' encoding='UTF-8'?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
<af:panelStretchLayout id="psl1">
<f:facet name="center">
<af:panelGroupLayout layout="vertical" id="p1">
<af:outputText id="o1" value="Hello View 1"></af:outputText>
<af:button id="b1" text="Load View 2" action="openview2"></af:button>
</af:panelGroupLayout>
</f:facet>
</af:panelStretchLayout>
</jsp:root>
Second View view2.jsff
<?xml version='1.0' encoding='UTF-8'?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
<af:panelStretchLayout id="psl1">
<f:facet name="center">
<af:panelGroupLayout layout="vertical" id="p1">
<af:outputText id="o1" value="Hello View 2"></af:outputText>
<af:button id="b1" text="Load View 1" action="openview1"></af:button>
</af:panelGroupLayout>
</f:facet>
</af:panelStretchLayout>
</jsp:root>
When run the JSPX file Hello View 1 and the button Load View 2 appears, but clicking on the button nothing happens
I am also getting this warning at action="openview1"
The action value does not match a navigation case outcome
I tried the auto completion goto in eclipse with action="view1"
still the button does nothing

Zend Framework - how to apply icon in xml file and retriev it

When it load the xml file, the icon cause failure inside the label tags. How to fix it?
// horizontal top menu
<?xml version="1.0" encoding="UTF-8"?>
<root>
<nav>
<page1>
<label><img src='icon.icon' /> Page 1</label>
<controller>index</controller>
</page1>
<home>
<label>Home</label>
<controller>index</controller>
</home>
</nav>
</root>
// controller test
$config = new Zend_Config_Xml(APPLICATION_PATH . '/configs/navigation.xml', 'nav');
$container = new Zend_Navigation($config);
$this->view->navigation($container);
I suppose you could do it with CSS instead
// horizontal top menu
<?xml version="1.0" encoding="UTF-8"?>
<root>
<nav>
<page1>
<label>Page 1</label>
<controller>index</controller>
<class>menu-page1-icon</class>
</page1>
</nav>
</root>
CSS
.menu-page1-icon:before {
content: url(path/to/icon.icon);
}
It should probably be in a cdata section:
<?xml version="1.0" encoding="UTF-8"?>
<root>
<nav>
<page1>
<label><![CDATA[<img src='icon.icon' /> Page 1]]></label>
<controller>index</controller>
</page1>
<home>
<label>Home</label>
<controller>index</controller>
</home>
</nav>
</root>
http://msdn.microsoft.com/en-us/library/ms256076.aspx