The Stack Overflow podcast is back! Listen to an interview with our new CEO.

New answers tagged

0

how i can add a class or id to new tab?


2

You can use this script to get category product collection randomly and you can exclude items which is not require.. <?php $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $categoryInstance = $objectManager->create('Magento\Catalog\Model\CategoryFactory'); $categoryId = 4; $excludeProductIds = array(2,3,4,5,6); ...


1

Before using the New Product function and page, you must first visit the configuration page for the Site that you want the product to pertain to. Stores > All Stores > [select Web Site] > On that config page, check the Set as Default button. Now start the Add New Product process. Way down the Product configuration page there's a setting for "...


1

You need to follow below steps : I have also 2 websites, Please check below screenshot. When I go to my product, which I have installed using Magento Sample Data, I can see only single website is available there. Please check screenshot. Now scroll down into that product and go to "Product in websites" tab. Please check below screenshot. And there is ...


2

get the productdata by id or sku i am using getbyId $productData = $this->productRepository->getById($productId); $attributeValue = $productData->getAttributeText("attribute_code");//pass your attribute code


0

You can load your option label using this. You just need option ID here. <?php $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $connection = $objectManager->get('\Magento\Framework\App\ResourceConnection')->getConnection(); $attributeOptionCollection = $objectManager->get("\Magento\Eav\Model\ResourceModel\...


1

you have write on block class file <?php namespace Pradip\Magegig\Block; class Products extends \Magento\Framework\View\Element\Template { protected $_productCollectionFactory; public function __construct( \Magento\Backend\Block\Template\Context $context, \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory $...


0

Please check the link. Which have all the answer of your question. Thanks


0

$porductIds=array(2,6,7); $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $productCollection = $objectManager->create('Magento\Catalog\Model\ResourceModel\Product\Collection'); $collectionByIds = $productCollection->addAttributeToSelect('*'); $collectionByIds->addFieldToFilter('entity_id', array('in' => $data)); ...


0

You may want to look at this file and override same within your own module in app/code or app/design


0

I found a way by simply querying the database directly for such info


0

Use priority tag like below <arguments> <argument name="priority" xsi:type="string">REPLACE WITH SOME NUMBER</argument> </arguments> example code <referenceBlock name="product.info.details"> <referenceBlock name="product.info.description"> <arguments> <argument name="...


0

Try below code if($_product->getTierPrice()){ $tier_price = $_product->getTierPrice(); foreach ($tier_price as $key => $value) { $qty = (int)$value['price_qty']; $price = $value['price']; $formattedPrice = $this->helper('Magento\Framework\Pricing\Helper\Data')->currency(number_format($price, 2), true, false); ...


0

Try below code to get custom option value $customOptions = $objectManager->get('Magento\Catalog\Model\Product\Option') ->getProductOptionCollection($_product); if (empty($customOptions)) { //check if product has custom options. If it doesn't go to the next product continue; } foreach($customOptions as $option) { $values = $option->...


0

Please try with below code in product listing page : $tier_price = $_product->getTierPrice(); if(count($tier_price) > 0){ foreach($tier_price as $pirces){ foreach ( array_reverse($pirces) as $key => $value ) { if($key == "price"){ $tierprice = number_format($value, 2, '.', ''); echo $tierprice; } hope ...


0

In Magento 2.3, they have added a sort-order to the tab block definitions that you set in layout XML. In the meantime, while continuing to use 2.2, you will have to do some custom code, as the "before" and "after" directives don't work for this. I recommend you reference this Inchoo blog post: https://inchoo.net/magento-2/customising-product-info-tabs-...


1

I think you are going right, you can improve it as: Execute cron at each minute and set limit value() as per the number of products in collection so that in each cycle of 5 minute, all the products description gets updated. Also note the time difference between job executed_at and finished_at If it is taking more than 60 seconds for each execution, ...


0

Single quoted strings will display things almost completely "as is." Variables and most escape sequences will not be interpreted. The exception is that to display a literal single quote, you can escape it with a back slash \', and to display a back slash, you can escape it with another backslash \ (So yes, even single quoted strings are parsed). Double ...


0

It seems that your endpoint only points to the EN scope, your default view. If you connect to endpoints /rest/V1/products the data is stored in the default store view. Write to the globale scope can be done with endpoints like this: /rest/all/V1/products. On the other hand you can use the "storeviewcode" to update specific views. For this task you can ...


0

You can save the product data for store views with the below code. $sku = 'E20630'; $product = $this->getProductBySku($sku); $storeIds = [1,2,3,4]; //add store ids comma seprated here if ($product) { foreach ($storeIds as $storeId) { $attribute_code = 'name'; $value = 'Storeview Specific Name'; $product->...


0

You have to reindex, you can do it like this : php bin/magento indexer:reindex


0

Please check using create custom script and add below code : // get token $userData = array("username" => "addyourusername", "password" => "yourpassword"); $ch = curl_init("https://demo.com/index.php/rest/V1/integration/admin/token"); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($userData)); ...


1

You want to use javascript Something like this https://stackoverflow.com/a/41121797/10121426 Assuming that your href attribute is linking to a div with the tag id with the same name (as usual), you can use this code: HTML <a href="#goto" class="sliding-link">Link to div</a> <div id="goto">I'm the div</div> JAVASCRIPT - (...


0

You can also rewrite functinality with plugin 1.Create di.xml file at Vendor/Module/etc and add below code <?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\Review\Controller\Product\Post"> ...


0

Create Namespace\Module\etc\di.xml and add the code below. <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> <preference for="Magento\Review\Controller\Product\Post" type="Namespace\Module\Controller\Product\Post" /> </config> create ...


0

Data-migration-tool tools often delete previous data like product and categories in Magento 2.So better download the CSV first and after migration of product upload the CSV from admin.Hope it will help


0

The best way is to make custom templates for different categories and specify it in Layout Update XML field of the category on which you want it to be.


1

You should read the doc about import process. This link can be usefull too to know wich fields must be set for your usecase : https://docs.magento.com/m2/ce/user_guide/system/data-attributes-product.html


0

Please use Magmi to import/update product with custom field in Magento 2. Magmi is import product data fast and direct on database. Magmi also create Select box options value automatic. Please referee sample CSV file for product custom field sku price custom_field1 PR-MB01 31 abx PR-MX02 32 pqr PR-UG04 94 ty ...


0

Did you try to run image resize command for product image not showing? php bin/magento catalog:images:resize


1

Add a new column called Stock while creating the order in the admin need to override the class \Magento\Sales\Block\Adminhtml\Order\Create\Search\Grid and add column qty_in_stock Follow below step to create custom module to add custom column. Step 1) magento/app/code/Venodr/SalesordercreategridStock/registration.php <?php \Magento\Framework\...


0

Fixed this. Used a javascript file to just pull and using find function to grab the cart counter number. Then just use show and hide on the content that on want to display dependant on whether the counter is greater than 0 or not.


0

some corrections & changes i had to implement to meets answer use catalog_product_delete_before event because getting $product->getCategoryIds() after product was deleted is returning an empty array use a query for product visibility before creating the rewrite because a rewrite is not needed for invisible products


0

If you don't want to display product on frontend. You need to change the product Visibility to Not visible individualy using below admin product path. Admin Path: Admin >> Catalog >> Products >> Edit Product >> Visibility: Not Visible Individually Hope it help!


0

Let's focus on the image problem. Take a product, write it's product id and check if there are images associated Launch the following sql query SELECT * FROM catalog_product_entity_media_gallery_value_to_entity as A, catalog_product_entity_media_gallery as B WHERE A.value_id = B.value_id AND A.entity_id = [YOURPRODUCTID] Check your tables name and ...


1

For this, in product listing click you have to set your custom controller URL (brands) (in that URL you have also pass product id). When any of click any of the product then first it's going on your custom module. After that for brand selection send data to the product view page. I hope so it's use full.


1

Please change the visibility of the product to Not visible individualy and it will not display at all in frontend. Thanks


1

Please check this Magento Devdocs page. It is clearly said that they do not recommend creating new entities (products, categories, attributes, etc.) in your Magento 2 store before migration because the Data Migration Tool overwrites such new entities with the old ones from Magento 1. So, you need to do first import export of the products and then you need ...


0

Please Create product-save.php file at magento root directory, add below code and run url :http://yourdomain/product-save.php or you can run script via command line <?php error_reporting(E_ALL | E_STRICT); $mageFilename = 'app/Mage.php'; require_once $mageFilename; Mage::setIsDeveloperMode(true); ini_set('display_errors', 1); ini_set('memory_limit', '...


1

You can do this in the category configuration from the Magento admin. Catalog > Category > Select category to change the layout. Please see attached screenshot for more information. Hope this helps!!!


0

Magento told you that you don't have permissions to write in /var/cache folder, please check what are the permission of the /var folder. Overview of ownership and permissions Magento 2


0

<?php // logined customer if ($order->getCustomerFirstname()) { $customerName = $order->getCustomerName(); } else { // guest customer $billingAddress = $order->getBillingAddress(); $customerName = $billingAddress->getFirstname() . ' ' . $billingAddress->getLastname(); } echo $customerName; ?>


0

I faced this issue. I fixed this issue by remove ifconfig for referenceBlock in my custom module xml file. Reason: You can use ifconfig attributes only on block, ui_component, action. referenceBlock does not allow this attribute. So kindly check ifconfig in your project. The following command will be useful for you. grep -r "ifconfig" app/ Then find ...


0

You will run delete query on catalog_product_entity table then below tables record will be deleted as entity column of catalog_product_entity is be related using the foreign keys: catalog_category_product catalog_compare_item catalog_product_bundle_option catalog_product_bundle_price_index catalog_product_bundle_selection catalog_product_entity_datetime ...


0

Please check below guide which will help you. https://amasty.com/knowledge-base/how-to-set-magento-2-recently-viewed-products.html or you can also do my xml layout to do this vendor/magento/theme-frontend-luma/Magento_Catalog/layout/catalog_product_view.xml for testing purpose <referenceContainer name="content"> <block class="Magento\Reports\...


2

You can follow this link magento 2.2.2 - How to transfer the product thumbnail to the left side Modify your theme view.xml file <vars module="Magento_Catalog"> <var name="gallery"> <var name="navdir">vertical</var> <!-- Sliding direction of thumbnails (horizontal/vertical) --> </var> ...


0

you can easily do it by css, Please add this following css in your existing css file: .fotorama__stage__shaft.fotorama__grab { margin-left: -120px !important; }


0

You may listen to catalog_product_save_after event and start comparing the new and old value to trigger an email sending event. Magento 2 seems to have native feature for product alerts.


0

Add cms_index_index.xml in vendor/module/view/frontend/layout/cms_index_index.xml then add the following code to the xml <?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"&...


4

You can do it in the following way. Create the new product attribute set enable for redirect products. Now Create event using your custom module (NOTE: If you don't have any module then create new module and then create event in that) So in your events.xml add following code /app/code/Vendor/Module/etc/events.xml <?xml version="1.0" ?> <config ...


Top 50 recent answers are included