New answers tagged

0

Please run below command: php bin/magento setup:upgrade php bin/magento setup:static-content:deploy -f php bin/magento cache:clean chmod -R 777 pub/ var/ generated/ app/


0

Please check with below code to do, get configurable products collection with options. <?php use Magento\Framework\App\Bootstrap; require __DIR__ . '/app/bootstrap.php'; $bootstrap = Bootstrap::create(BP, $_SERVER); $obj = $bootstrap->getObjectManager(); $state = $obj->get('Magento\Framework\App\State'); $state->setAreaCode('frontend'); $...


0

You can check module-configurable-product in Magento You can override configurable.phtml file to your module. vendor/magento/module-configurable-product/view/frontend/templates/product/view/type/options/configurable.phtml As i said in comments, you can check condition like this $product->getTypeId()=="configurable" and show your html according to ...


0

class Rule extends \Magento\CatalogRule\Model\Rule { public function getRuleByProduct($product){ $priceRules = null; $rd = null; $productId = $product->getId(); $price = $product->getPriceInfo()->getPrice('regular_price')->getAmount()->getValue(); $storeId = $product->getStoreId(); $dateTs = $this->_localeDate-&...


0

I add my discoveries as a new answer so it has better visibility and can be up-voted. Indeed there was some files naming / folder structure mistakes. But this is not enough... TL;DR : Add a sort_order value to your tab block : <argument name="sort_order" xsi:type="string">99</argument> Be sure this sort_order value is UNIQUE among other tabs ...


0

This is an update for Magento 2.2 and 2.3 --- the proper way to remove this is to override a JavaScript file into the active theme, and remove a section of code The culprit is vendor/magento/module-configurable-product/view/frontend/web/js/configurable.js - line 415 // vendor/magento/module-configurable-product/view/frontend/web/js/configurable.js // ......


0

You asked about fetching stock as part of collection $collection = Mage::getModel('catalog/product') ->getCollection() ->addAttributeToSelect('*'); foreach ($collection as $product) { Zend_Debug::dump($product->getStockItem()->debug()) echo $product->getStockItem()->getIsInStock(); } You can also do it this way too. ...


1

if you load the product like $product = Mage::getModel('catalog/product')->load($id);, to get the qty available for the product, you can do $qty = $product->getStockItem()->getQty(); and to check if the product is in stock: $isProductInStatus = $product->isInStock(); In block: $product = Mage::getModel('catalog/product')->load($id); $...


0

I've had mixed results with the method you have used Instead I do this public function __construct( \Magento\Catalog\Model\Product\Gallery\Processor $galleryProcessor, } { $this->galleryProcessor = $galleryProcessor; } https://github.com/DominicWatts/Faker/blob/master/Helper/Product.php#L351 $this->galleryProcessor->addImage($product, $...


0

You have not provided information that how you have created variations. Have you assigned price to different price to all variants? I have created configurable product with 4 variants as you shown with 2 scenario. I have used Magento 2.2.8(CE). Have not assigned price(in this case it will take same price as configurable) and checked that price is not ...


1

Let turn on debug mode in Magento. Uncomment/add this code into app/bootstrap.php error_reporting(E_ALL); ini_set('display_errors', 1); Reload the product page to see the error message.


0

Run these commands php bin/magento setup:static-content:deploy -f php bin/magento cache:clean


1

Thank you for answering my questions in comments section. You've got a few options. More resource on stack. More CPU. But even the you are going to struggle to get close to numbers you are talking about. Using nginx or maybe varnish will offer more improvements. Redis will help on high traffic stores. So if you've got a lot of traffic on top of large ...


0

I also had the same issue, but i also wanted to merge js files for front-end. So what i did was, i disabled js merge for admin and enabled it only for front-end.


-1

Resolved with the solution is this link: https://github.com/magento/magento2/issues/12483


1

Finally achieved by following steps. 1) One of the reasons that passing the same product Id as said @KKR, @CoderGeek, and @AdarshM. 2) Product is created with Qty = 0, Price = 0, Stock Maintenance = No and Search = Notvisible. When I am trying to add the product programmatically it's not added because of Saleable is returning false and not the stock of ...


0

You can get id in params, $this->getRequest()->getParams(); Or $this->request->getParam('product_id'); // Use this class in construct() \Magento\Framework\App\RequestInterface In your Controller file protected $request; public function __construct( \Magento\Framework\App\RequestInterface $request ) { $this->request =...


2

You can get Current Product by creating custom module or by object manager, But I am not refer to use as Object Manager 1. Using Module Create file app/code/Vendor/Module/Block/Product.php and add following Code. <?php namespace Vendor\Module\Block; class Product extends \Magento\Framework\View\Element\Template { protected $_registry; ...


1

Remove this code : <?php echo $this->getUrl('history/detail/display',['item_id' => $item->getItemId()]); ?> And add this code for redirect to product page : <?php echo $_product->getProductUrl(); ?>


1

It seems there are two product passed with the same product_id. It should be different product_id. Please try same code but with different Product Id. e.g. ['product_id' => '2', 'qty' => 1, 'name' => 'Test Product 1', 'sku' => 'ts1', 'price' => 250 ], ['product_id' => '2', 'qty' => 2, 'name' => 'Test ...


0

You have two products with the same product_id, so the quantity gets added up and the price is overwritten from the final duplicate product.


0

Some Other Approaches Using ResourceConnection Method <?php namespace Vendor\Package\Controller\Custom; use Magento\Framework\Controller\ResultFactory; class DeleteRecord extends \Magento\Framework\App\Action\Action { protected $connection; protected $resource; protected $resultRedirect; protected $messageManager; public function ...


0

You are passing the same product_id, try changing that and it should add both the products to the order. It is also adding the qty ordered and overwriting the price.


0

If you have the product available, you can use this logic to check if it is a new product: /** * Check if the given product is new and return true if it is. * * Should the Magento logic change, look in vendor/magento/module-catalog/Block/Product/NewProduct.php * * @param ProductInterface $product * @return boolean */ public function showNewLabel(...


2

We can't add customer based filters to ProductCollection in listing page. Collection will be cached and same collection will be served to all customers in PLP. Adding customer based filters is not recommended. You can achieve this by making listing page as non cacheable. Listing page loading time will be high.


0

Seem to be missing opening / closing brackets. Try this - { "product": { "sku": "B201-SKU", "name": "B202", "price": 30.00, "status": 1, "type_id": "simple", "attribute_set_id":4, "weight": 1 } }


0

Better use REST API's, I have to give the magento devdoc url: https://devdocs.magento.com/guides/v2.3/rest/tutorials/orders/order-create-quote.html


0

Solution: Clear cache (php bin/magento cache:flush) and (php bin/magento cache:clean) If this not solve your problem you may try to remove all static content and redeploy


0

Please, you replace only your following code <columns name="spinner_columns"> <column name="entity_id"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> <item name="label" xsi:type="string" translate="true">Product Id</item> </item> </argument> &...


0

Found the Solution. Extended Magento\Catalog\Ui\DataProvider\Product\ProductDataProvider for my custom provider (InventoryDetail).


0

I'm late, i know. But i found the following solution(class) in Magento 2 Framework. vendor/magento/framework/Filter/Truncate.php The class have same code like: app/code/core/Mage/Core/Helper/String.php -> helper('core/string')


0

Please try with below url : https://stackoverflow.com/questions/44624568/magento-2-create-order-programmatically-and-add-products-with-custom-options?rq=1 I hope its work for you.


0

I can suggest that you are not defined you collection in di.xml <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd"> <type name="Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory"> <arguments> ...


-1

Your code is too verbose. Why don't use Magento\Sales\Model\Order? This is my example: $order = $this->_objectManager->create('Magento\Sales\Model\Order') ->setStoreId($store_id) ->setQuoteId(0) ->addData($orderData); ->setBillingAddress($billingAddress) ->...


0

Below code solve the issue:- <?php $objectManager =\Magento\Framework\App\ObjectManager::getInstance(); $helperImport = $objectManager->get('\Magento\Catalog\Helper\Image'); $imageUrl = $helperImport->init($_product, 'product_page_image_small') ->setImageFile($_product->getFile()) // image,small_image,thumbnail ->resize(300) ->getUrl(); ...


3

First you have to add block in your module Path: app\code\Vendor\Module\Block\Crumbblock.php <?php namespace Vendor\Module\Block; use Magento\Catalog\Helper\Data; use Magento\Framework\View\Element\Template\Context; use Magento\Store\Model\Store; use Magento\Framework\Registry; class Crumbblock extends \Magento\Framework\View\Element\Template { /*...


1

In Magento 2,You can use this simple module for any slider. https://github.com/vrajeshkpatel/magento2-owlcarousel


2

in your theme app/design/frontend/Vendor/YourTheme/requirejs-config.js add owlcarousel js entry: var config = { paths: { 'myowl': 'Vendor_Module/js/owl.carousel' }, shim: { 'myowl': { deps: ['jquery'] }, } }; then call owl carousel in any phtml file or js file using this: require(['jquery','myowl'],function($){ $(document).ready(...


5

First, you load product using product id like $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $product = $objectManager->create('Magento\Catalog\Model\Product')->load($data->getProductId()); After that, get the URL of the image $imageHelper = $objectManager->get('\Magento\Catalog\Helper\Image'); $image_url = $...


0

for this, you have to upload the image of the same dimensions for all products you want if you upload the image of different dimension it will create this issue. this issue can be solved by CSS but it is not recommended because some time image might get stretched out so the best solution is to upload the image of the same dimensions for all products


2

you can create a configurable product for this situation, in that you have to give two option first option to select curtain shape and second option for select size for that type of curtain.


0

Make an observer on the catalog_category_save_after event for the adminhtml. In the observer you can retrieve the category object and write your logic there. In general; Create Event Retrieve category that is saved in observer. Retrieve all products from this category and based on the status of the category you can loop through these products to set them ...


2

can you please check your Magento version because this is the default Magento bug in Magento version 2.3.1 and 2.3.2 and might be for other versions too


1

Try below code with changes according to your needs, and do not use object manager in original implementation. $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $orderItemCollection = $objectManager->create('\Magento\Sales\Model\ResourceModel\Order\Item\Collection'); $orderItemCollection->addFieldToFilter('order_id', ORDER_ID); $...


0

I suggest to take a look at collections in Magento 2. You can create a filter that you can use on the collection to filter the products you need based on your (custom) attributes. The collection contains the products you need, like in your example all products who has a specific color or a product with a specific ean. Have a look at the following link; ...


0

Try below code Override following file: app\design\frontend\theme_namespace\yourtheme\Magento_Catalog\templates\product\view\options\type\select.phtml Now try with below code: <script> require([ 'jquery', 'domReady!' ], function ($) { $(document).ready(function () { $('select.product-custom-option')....


0

You can able to extend below class where you can update configurable product options as required \Magento\ConfigurableProduct\Model\ConfigurableAttributeData function getAttributeOptionsData()


0

Open vendor\magento\theme-frontend-luma\web\ and copy "fonts" folder to your theme i.e. app\design\frontend\Package\Theme\web It should work


0

Is the issue that what is returned from $_product->getProductUrl() is different to the add to cart action? e.g you are getting http://your-site/catalog/product/view/id/123 (or something similar) rather than http://your-site/nice-url.html? If this is the case I'd try one of 2 things. Are friendly URLs enabled for your store? I believe this is store->...


3

This is not an issue. When index updated using "Update on Save" this will not set last updated date. Whereas if you run indexing manually then it will set last updated date. Just make sure you have enabled magento cronjobs by this command: php bin/magento cron:install For detail of Magento indexing you can follow my answer here: https://magento....


Top 50 recent answers are included