In Magento 2 display recently viewed product on product detail page - block

I want to display recently viewed products on product detail page in Magento 2. I am using Magento ver. 2.1.2. Please assist me how to display it.
Thanks

in your catalog_product_view.xml file add below block in
<block class="Magento\Reports\Block\Product\Widget\Viewed" after="-" name="recently_viewed" cacheable="false" template="Magento_Reports::widget/viewed/content/viewed_grid.phtml">
<action method="setPageSize">
<argument name="page_size" xsi:type="number">4</argument>
</action>
</block>

We should not set cacheable="false". This will greatly impact the performance. The whole page will be uncacheable.
1) 2.1.x: seems that it's a Magento bug with FPC and Varnish: https://github.com/magento/magento2/issues/3890. In this case, I used Ajax.
2) 2.2.x or later: using UI component: https://magento.stackexchange.com/a/209658/33057

\Magento\Reports\Model\ResourceModel\Product\CollectionFactory
$_reportCollectionFactory
$this->_reportCollectionFactory = $_reportCollectionFactory;
$collection = $this->_reportCollectionFactory->create()
->addAttributeToSelect('*')
->addViewsCount()
->setStoreId($storeId)
->addStoreFilter($storeId)
->setPageSize(10);

Related

JSF2 custom component, parameter autocompletion with a local file path

My First Question, after years, thank you all and stackoverflow ;-)
I code a new Component for JSF2 and use it to include other templates.
It works perfectly for me.
<cc:interface>
<cc:attribute name="src" type="java.lang.String" required="true"/>
<cc:attribute name="addOption" type="java.util.List"/>
</cc:interface>
<cc:implementation>
<cc:insertChildren />
<ui:include src="#{BeanAnything.convert(cc.attrs.src, cc.attrs.addOption)}" />
</cc:implementation>
But i cant complete the Parameter src via auto completion in intellij or netbeans with "strg + space" or whatever other will use.
It should be used like the ui:include on src parameter.
Any Ideas ?
That's what I want to achieve only with my own componente gg:include
See Example

Cannot create work item control of type "MultiValueControl"

I have tried to install the latest version of the MultiValueContol for TFS 2015 update 3. I have it working when you are in Visual Studio. You can see the checkbox and it works. If I define the type as MultiValueControl (see test1 below) it works in VS but in the web I get an error message: Cannot create work item control of type "MultiValueControl"
I found an article that said define it as type=FieldControl and PreferedType=MultiValueControl.. (see test2 below) This works on VS ok, but on web access it shows me the 2 entries I selected when I created the WIT in VS, but when you select it acts as a fieldcontrol and only allows me to choose one item in the list. Based on the earlier warning in the Web access page, the browser page can't load that control.?
I have tried the following xml configs.
Test1:
<FIELD name="Technology Domain" refname="WPS.TechnologyDomain" type="String" reportable="dimension">
<SUGGESTEDVALUES expanditems="true">
<LISTITEM value="[Item 1]" />
<LISTITEM value="[item 2]" />
</SUGGESTEDVALUES>
</FIELD>
and
Test2:
<FIELD name="Technology Domain" refname="WPS.TechnologyDomain" type="String" reportable="dimension">
<SUGGESTEDVALUES expanditems="true">
<LISTITEM value="[Item 1]" />
<LISTITEM value="[item 2]" />
</SUGGESTEDVALUES>
</FIELD>
I'm not sure what to check next.
Seems you are using the extension Custom Controls for TFS Work Item Tracking. According to the responses from author :
#PatDelaney, The latest version of the control refactored to support
the new TFS "15". For TFS 2015 you should use the older version
http://witcustomcontrols.codeplex.com/releases/view/620316. Let us
know if this helps
Reply by kabalas (Coordinator) at 5:11 AM
Please have a try with the old version as suggested.

I want to display all the comments of one particular product in magento

I want to display all the comments of one particular product in magento. For example for Each Product it have to show the comments of that particular product only.
If you want to display the Reviews on the product page you can use the code below:
Step 1. You have to edit the catalog.xml file you can find it by navigating to the app/design/frontend/YourPackage/YourTheme/layout/catalog.xml
Step 2. Add this block under the catalog_product_view
<block type="review/product_view_list" name="product.info.product_additional_data" as="product_review" template="review/product/view/list.phtml">
</block>
Step 3. Now call this particular block into the view.phtml page you can find it by navigating to the app/design/frontend/YourPackage/YourTheme/template/catalog/product/view.phtml
Step 4. Add this chunk of the code where you want to display the review on this page
<?php echo $this->getChildHtml('product_review') ?>
That's it hope it helps.
Thanks

Shopify: Is it possible to find a product by sku number?

The data that I'm getting only contains the SKU numbers. I am trying to figure out how I can link these SKU numbers to the product variants in Shopify without the actual product id number.
Example data:
<Inventory ItemNumber="100B3001-B-01">
<ItemStatus Status="Avail" Quantity="0" />
</Inventory>
<Inventory ItemNumber="100B3001-B-02">
<ItemStatus Status="Avail" Quantity="0" />
</Inventory>
<Inventory ItemNumber="100B3001-B-03">
<ItemStatus Status="Avail" Quantity="-1" />
<ItemStatus Status="Alloc" Quantity="1" />
</Inventory>
<Inventory ItemNumber="100B3001-B-04">
<ItemStatus Status="Avail" Quantity="-1" />
<ItemStatus Status="Alloc" Quantity="1" />
</Inventory>
Here's a delightful, condescending discussion from Shopify employees in 2011 asking why you can't just store the Shopify ID everywhere. The "stock-keeping unit" is a universal systems integration point and, in every system I've seen, each SKU uniquely maps to a product because words have meaning, but apparently not at Shopify.
Three years later, you seem to have two options.
One is to create a Fulfillment Service and provide a URL where Shopify will call you asking for stock levels on a SKU; this is probably the simplest solution, provided you have a Web server sitting somewhere where you can expose such a callback.
The second is to periodically page through all of the Products and store a mapping of the Shopify ID to a SKU somewhere, consulting your map when you need to do an update. Because most of our integrations are cron jobs and I'd like to keep them that way, I periodically ask for the products that have changed since the last run, and then update my mapping.
As David Lazar points out in his comment, the ability to find a product based on its SKU is not currently supported in the Shopify API.
EDIT: This is an unreliable option that I once used as a last resort. I wouldn't recommend using this but I will leave it here in case as someone may find it helpful.
You can use this API endpoint:
/admin/products/search.json?query=sku:abc123
I have only used it in the browser though, and I can't find any documentation for it. And it may stop working at any time.
You can use
*.myshopify.com/search?view=json&q=sku:SKUID
Graph query on Shopify works for me:

Changing the ALLOWEDVALUES in tfs2010 to a AD group

I have a little problem with a work item.
My goal is to change the <ALLOWEDVALUES> of a work item to an AD group, so that not all "ValidUsers" can get a work item assigned. For this I've created a new TFS group "TFS_AssignGroup" and added the AD-group (AD-TFS_AssignGroup) to it.
Now I've changed the work item type definition:
<FIELD name="Assigned To" refname="System.AssignedTo" type="String" syncnamechanges="true" reportable="dimension">
<HELPTEXT>The person currently working on this bug</HELPTEXT>
<ALLOWEDVALUES expanditems="true" filteritems="excludegroups">
<LISTITEM value="[project]\TFS_AssignGroup" />
</ALLOWEDVALUES>
</FIELD>
Now I expected, that the AssignedTo-field only shows the people, who are in the AD-group. But it actually only shows me the AD-group itself. So I have exactly one entry in my AssignedTo-field: AD-TFS_AssignGroup.
Any idea?
Ok, that was an easy one: It just took some time to get the data from the AD. So the solution is to do nothing and wait (or restart the TFS server).