New answers tagged

0

I hope it would be helpful for you. In below code I have used orderCollectionFactory to retrieve custom attribute value: namespace Vendor\ModuleName\Model; use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory as ProductCollection; use Magento\Sales\Model\ResourceModel\Order\CollectionFactory; class YOURClass { /** * @var ...


0

You can use the below code or create a new file in app/code/Vendor/CustomBlock/view/frontend/layout/catalog_product_view.xml Then you can add below content <?xml version="1.0"?> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/...


-1

Apply AllowEncodedSlashes directive in Apache go to http.conf (or any conf file in sites-available) <VirtualHost *:80> ... AllowEncodedSlashes On ... </VirtualHost>


0

Get the collection in your block file public function getOrderCollection() { $collection = $this->_orderCollectionFactory->create(); $collection->addAttributeToSelect('*'); $collection->addAttributeToFilter('your_attribute_code_here', 1); $collection->setOrder('created_at','desc'); return ...


0

I FOUND THE SOLUTION! This is the complete code for add to cart multiple items programmatically that i write. I hope this help someone ;) <?php namespace Catalog\Product\Controller\Index; use Magento\Framework\Controller\ResultFactory; use Magento\Framework\App\Action\Action; use Magento\Framework\App\Action\Context; use Magento\Framework\Data\Form\...


1

You can get it with $item->getProduct()->getData('attribute_code_here') But there is a problem. Actually a few: Product may have been deleted the attribute value has been changed after the order was placed. the attribute may have been deleted The best approach would be to save the value of the product attribute on the order item when the order is ...


1

You need to start emulation using this below code : $this->appEmulation->startEnvironmentEmulation($storeId, \Magento\Framework\App\Area::AREA_FRONTEND, true); After that, you can get product image full url in your rest api. For more details : Click Here Hope, It will helpful for you.


0

Short answer: no You'll need to send the base64 encoded image in the base64_encoded_data param


0

I found the answer, i looked at the admin menu -> stores -> attribute set, and the custom attribute was unsigned. so i passed it to signed.


0

Please share your code so we can see how you create the two custom attributes. are the two attributes different from each other? maybe one is text/select/multiselect etc. We can't help you without the related code or specific informations. docs: https://devdocs.magento.com/videos/fundamentals/add-new-product-attribute/ Cheers


0

You need to do this reindexing programmatically : catalog_product_attribute If you want to do from admin, then you can also do it.


1

I solved this following this tutorial Magento 2 : How to load quote by quote id looks like the load function is depreciated and doesn't works anymore.


0

This question has been asked before. What is the use of 'Cost' attribute in Catalog product in magento 2 Answer: It's saved to the quote and to other documents. The (purchase)cost of an item can go up or down, Because of this, the gross margin can be calculated per product even when the order is a few months old.


1

I am assuming your attribute code is external_link Now copy: vendor/magento/module-catalog/view/frontend/templates/product/view/attributes.phtml to app/design/frontend/{Package}/{theme}/Magento_Catalog/templates/product/view/attributes.phtml Now we will add an if condition for external_link code and add a tag like: <?php if($_data['code']=='...


3

customize the code according to your requirement i have written it for one my work where i needed to export products from magento 1. i this code am just taking the sku, id , and price you can take other things as well if you want. <?php // output headers so that the file is downloaded rather than displayed header('Content-Type: text/csv; charset=utf-8'...


1

You can use the updateAttribute function to update the existing product attribute easily with storewise also. Here is the sample Code: $updateAttributes['case_back'] = "Black"; $updateAttributes['case_material'] = "Silver"; $action = objectManager->create('\Magento\Catalog\Model\ResourceModel\Product\Action'); $action->...


0

Try to remove generated/code/* and var/cache/*. Run the php bin/magento indexer:reindex and check again. Check if the attribute configurableExi... has frontend_label value! ((Magento\Framework\View\Element\UiComponentFactory->mergeMetadataElement(Array, 'configurableExi...', NULL, false) #1) ) Check if frontend_input value of the attribute is valid and ...


1

If you using console command for this propose that is very fast an useful things. For console command you need to do this below code. In between you have to put the product update csv in var/upload/ folder or you select other folder. add below code in di.xml file in app\code[Vendor][Namespace]\etc <?xml version="1.0"?> <config xmlns:...


2

In order to update product attribute programmatically I use below way which is much faster then to save whole object public function __construct( ..... \Magento\Catalog\Model\ResourceModel\Product\Action $productAction, ...... ) { $this->productAction = $productAction; } public function saveProductAttribute() { $cnt = 0; ...


1

I have a solution working on my local environment. Before posting the full solution, I'd like to verify your requirements: we are after something that performs faster than your solution but you do not specify whether the speed is over 1 sku, many skus or 1000.. My import has pros and cons: I do not claim it competes with Magento and it is not ready for ...


0

Create an Attribute in admin with text type say external_link Add phtml at: app/design/frontend/{Package}/{theme}/Magento_Catalog/layout/catalog_product_view.xml <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/...


0

Then you need to do the following things. first create one product attribute where you mention this link of third party. Now create one custom extension and create custom phtml file and call the file on product page on specific by using reference block. Now in that phtml file, fetch that product attribute value and show to customer.


1

For Minicart update, You need to add action URL in sections.xml file like below ex. Create a sections file app/code/Vendor/Module/etc/frontend/sections.xml <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Customer:etc/...


1

I answered a similar question on this ticket, you can create a command import by using the default Magento import model. That means you can use Magento import template CSV file like UI at System -> Data Transfer -> Import / Export Ref: https://magento.stackexchange.com/a/318174/85035 Let me know if you need a more detailed script. Thanks


1

I think you should fire the query directly on URL Rewrite table. $productUrl = Mage::getResourceModel('core/url_rewrite') ->getRequestPathByIdPath('product/' . $productId, $storeId); ou can try getting the product id as $product = $observer->getEvent()->getProduct(); $productId = $product->getId(); Hope it was helpful. Thanks


1

If you look at the function \Magento\Checkout\Controller\Onepage\Success::execute, you will see the code below: $this->_eventManager->dispatch( 'checkout_onepage_controller_success_action', [ 'order_ids' => [$session->getLastOrderId()], 'order' => $session->getLastRealOrder() ...


0

I have an idea for something similar but it leverages some data we already have in our system. We have an attribute on products like this that contains a set of SKUs, one of which must be selected and purchased along with the parent item. I'm going to make a Magento 2 Bundle Product containing all of the parent and children products in their respective ...


0

In magento 2.3.4 i get this like this. You can get all images of the product by gallery ReadHandler <?php namespace Vendor\Module\Controller\Index; class DownloadPictures extends \Magento\Framework\App\Action\Action { protected $_pageFactory; public function __construct( \Magento\Framework\App\Action\...


0

You can do it with n98-magerun2 if this is a one-shot task: If you want to delete categories with IDs 1, 2, 3, 4 $di->configure($di->get(\Magento\Framework\ObjectManager\ConfigLoaderInterface::class)->load('admin')) $di->get(\Magento\Framework\Registry::class)->register('isSecureArea', true); $cr = $di->get(\Magento\Catalog\Model\...


0

Because you may be exporting parent categories and it may not contain any products. Try exporting from the child categories where products are assigned to.


0

After insepecting the browser console I noticed alot of Content Security Policy errors. I solved them, now it works again. More infos


0

You want to update the attribute set for a product type: https://www.ubertheme.com/magento2/understanding-magento-2-product-attributes-attribute-sets/#:~:text=Some%20attributes%20are%20built%20into,2%20to%20customize%20your%20products.&text=Attribute%20set%20represents%20a%20list,to%20a%20specific%20product%20family. Check out this question/answer for ...


0

This should do it: <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/layout_generic.xsd"> <container name="product.info.form.content" as="product_info_form_content"> <update handle="catalog_product_opengraph" /...


0

issue was: cannot delete or update a parent row: a foreign key constraint fails (amasty_pgrid_qty_sold, constraint amasty_pgrid_qty_sold_ibfk_4 foreign key (product_id) references catalog_product_entity (entity_id) on delete no action on up) comment: we need to remove entry from amasty_pgrid_qty_sold before actual product delete from catalog_product_entity ...


0

its because of $product->save() when you save product with orm, its setting has_options to 0. Shortly its a magento bug. To fix that issue in db level, you can execute the query below. update catalog_product_entity t1 inner join catalog_product_option t2 on t2.product_id = t1.entity_id set t1.has_options = 1 where t1.has_options = 0 and t1.type_id = '...


Top 50 recent answers are included